You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

28 lines
507 B

  1. #include "config.h"
  2. /* Configuration words */
  3. _FOSC(FCKSM_CSECMD & POSCMD_XT);
  4. _FOSCSEL(FNOSC_FRC);
  5. _FWDT(FWDTEN_OFF);
  6. void config_init(void)
  7. {
  8. /* Disable analog inputs */
  9. AD1PCFGL = 0xffff;
  10. AD1PCFGH = 0xffff;
  11. AD2PCFGL = 0xffff;
  12. /* Configure PLL to multiply from 8 -> 40 MHz */
  13. PLLFBD = 38;
  14. CLKDIVbits.PLLPRE = 0;
  15. CLKDIVbits.PLLPOST = 0;
  16. /* Switch to XTPLL clock */
  17. __builtin_write_OSCCONH(0x03);
  18. __builtin_write_OSCCONL(0x01);
  19. /* Wait for lock */
  20. while (!OSCCONbits.LOCK)
  21. continue;
  22. }