zitroneneis

Kinetis K64F IRC48MHz initialization

Jan 9th, 2015
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1.   /* Enable the IRC48Mhz clock */
  2. #if (CLOCK_SETUP == 2) || (CLOCK_SETUP == 3) || (CLOCK_SETUP == 4)
  3.   SIM->CLKDIV2 = 0x00u;     /* Set USB Clock Divider Divisor and USB clock Divider fraction to 0 because 48MHz is the correct frequency already */
  4.   SIM_SOPT2_REG(SIM_BASE_PTR) |= SIM_SOPT2_USBSRC_MASK | SIM_SOPT2_PLLFLLSEL(3);    /* Configure USB to be clocked from IRC 48MHZ */
  5.   SIM_SCGC4_REG(SIM_BASE_PTR) |= SIM_SCGC4_USBOTG_MASK;     /* ungate clock to USB Module to allow configuration of module registers */
  6.   volatile uint8_t *usb_irc_en_adr = (uint8_t*)0x40072144u; /* IRC48M Oscillator enable register */
  7.   *usb_irc_en_adr |= BM_USB_CLK_RECOVER_IRC_EN_REG_EN | BM_USB_CLK_RECOVER_IRC_EN_IRC_EN;   /* Enable IRC48M and IRC48M regulator */
  8.   volatile uint8_t *usb_clk_recovery = (uint8_t*)0x40072140u;   /* USB Clock recovery control register */
  9.   *usb_clk_recovery |= BM_USB_CLK_RECOVER_CTRL_CLOCK_RECOVER_EN; /* Crysal-less USB enable */
  10. #endif
Advertisement
Add Comment
Please, Sign In to add comment