| Electronic Components Datasheet Search |
|
AN3995 Datasheet(PDF) 35 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN3995 Datasheet(HTML) 35 Page - STMicroelectronics |
|
35 / 49 page ![]() AN3995 Application code example Doc ID 022384 Rev 2 35/49 SWT.SR.R = 0xC520; /* Clear Soft lock bit in CR by writing */ SWT.SR.R = 0xD928; /* 0xC520 followed by 0xD928 to WSC field */ SWT.CR.B.WEN = 0x0; /* Clear Watchdog Enable Bit */ } /******** void MODE_Init(void) *********/ //! This function initialize the modes /*! \brief Enable system clock for all peripherals assuming 120MHz system cloc \return No return value. \retval void \note None */ void MODE_Init(void) { ME.MER.R = 0x000025FF; /* Enable all modes */ ME.RUNPC[0].R = 0x000000FE; /* Enable all peripherals in all modes */ /* Enable system clock for all peripherals assuming 120MHz system clock */ CGM.SC_DC[0].R = 0x83; /* Max 32MHz. Closest is 30MHz, Div+1=3 */ CGM.SC_DC[1].R = 0x81; /* Max 64MHz. Closest is 60MHz, Div+1=2 */ CGM.SC_DC[2].R = 0x81; /* Max 64MHz. Closest is 60MHz, Div+1=2 */ /* Re-enter DRUN mode to update the clock configuration */ ME.MCTL.R = 0x30005AF0; /* DRUN Mode & Key */ ME.MCTL.R = 0x3000A50F; /* DRUN Mode & Key */ while (ME.GS.B.S_MTRANS == 1); /* Wait for mode transition complete */ } /******** void PLL_Init(void) *********/ //! This function configure the PLL /*! \brief This function configure the PLL \return No return value. \retval void \note Switch on osc, change mode and wait for osc ON Configure and enable PLL, change mode and wait for PLL to lock Set clock source as PLL, change mode and check clock is PLL */ void PLL_Init(void){ ME.DRUN.B.FXOSC0ON = 1;/* Switch on external oscillator in DRUN mode */ /* Re-Enter DRUN mode (mode=0x3) to activate change */ ME.MCTL.R = 0x30005AF0; /* Mode & Key */ ME.MCTL.R = 0x3000A50F; /* Mode & Key inverted */ while(ME.GS.B.S_MTRANS == 1); /* Wait for mode transition complete */ while(ME.GS.B.S_CURRENTMODE != 3);/* Error trap - if current mode is not DRUN (eg in safe mode), then loop */ while(ME.GS.B.S_FXOSC != 1);/* Wait for external OSC to stabilize */ /* Select External OSC as the FMPLL Reference Clock Source */ CGM.AC0_SC.B.SELCTL = 0x0; /* Configure PLL for 120MHz with 40MHz xtal: PLL frequency = (40 * NDIV) / (IDF * ODF) */ /* NOTE: VCO (PLL * ODF) must be between 256 and 512MHz */ CGM.FMPLL_CR.B.IDF = 0x4; /* Divide by 5 */ CGM.FMPLL_CR.B.ODF = 0x1; /* Divide by 4 */ CGM.FMPLL_CR.B.NDIV = 60; /* Divide by 60 */ /* Enable PLL in DRUN mode. */ |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |