Вот так у меня работает. Правда кварц другой. Код void pll_init() { PCONP |= USB_CLK_ON; /* 1. Disconnect the PLL with one feed sequence if PLL is already connected. */ if ( PLLSTAT & (1 << 25) ) { PLLCON = 1; PLLFEED = 0xAA; PLLFEED = 0x55; } /* 2. Disable the PLL with one feed sequence. */ PLLCON = 0; PLLFEED = 0xAA; PLLFEED = 0x55; /* 3. Change the CPU Clock Divider setting to speed up operation without the PLL, if desired. */ CCLKCFG = 0; /* 4. Write to the Clock Source Selection Control register to change the clock source. */ SCS |= 0x20; /* Enable main OSC */ while( !(SCS & 0x40) ); /* Wait until main OSC is usable */ CLKSRCSEL = 1; /* 5. Write to the PLLCFG and make it effective with one feed sequence. The PLLCFG can only be updated when the PLL is disabled. */ PLLCFG = (PLL_NVAL << 16) | PLL_MVAL; PLLFEED = 0xAA; PLLFEED = 0x55; /* 6. Enable the PLL with one feed sequence. */ PLLCON = 1; PLLFEED = 0xAA; PLLFEED = 0x55; /* 7. Change the CPU Clock Divider setting for the operation with the PLL. It's critical to do this before connecting the PLL. */ CCLKCFG = CCLK_VAL; USBCLKCFG = USBCLK_VAL; /* 8. Wait for the PLL to achieve lock by monitoring the PLOCK bit in the PLLSTAT register, or using the PLOCK interrupt, or wait for a fixed time when the input clock to PLL is slow (i.e. 32 kHz). The value of PLOCK may not be stable when the PLL reference frequency (FREF, the frequency of REFCLK, which is equal to the PLL input frequency divided by the pre-divider value) is less than 100 kHz or greater than 20 MHz. In these cases, the PLL may be assumed to be stable after a start-up time has passed. This time is 500 µs when FREF is greater than 400 kHz and 200 / FREF seconds when FREF is less than 400 kHz. */ while (!(PLLSTAT & (1 << 26))){;} /* 9. Connect the PLL with one feed sequence. */ PLLCON = 3; PLLFEED = 0xAA; PLLFEED = 0x55; while ( !((PLLSTAT & (1 << 25))) ); /* Check connect bit status */
/* Set peripheral clock */ PCLKSEL0 = PCLK0_WDT(PCLK_1) | PCLK0_TIMER0(PCLK_1) | PCLK0_TIMER1(PCLK_1) | PCLK0_UART0(PCLK_1) | PCLK0_UART1(PCLK_1) | PCLK0_PWM1(PCLK_1) | PCLK0_I2C0(PCLK_1) | PCLK0_SPI(PCLK_1) | PCLK0_RTC(PCLK_4) | PCLK0_SSP1(PCLK_1) | PCLK0_DAC(PCLK_1) | PCLK0_ADC(PCLK_1) | PCLK0_CAN1(PCLK_1) | PCLK0_CAN2(PCLK_1) | PCLK0_ACF(PCLK_1);
PCLKSEL1 = PCLK1_BAT_RAM(PCLK_1) | PCLK1_GPIO(PCLK_1) | PCLK1_PCB(PCLK_1) | PCLK1_I2C1(PCLK_1) | PCLK1_SSP0(PCLK_1) | PCLK1_TIMER2(PCLK_1) | PCLK1_TIMER3(PCLK_1) | PCLK1_UART2(PCLK_1) | PCLK1_UART3(PCLK_1) | PCLK1_I2C2(PCLK_1) | PCLK1_I2S(PCLK_1) | PCLK1_MCI(PCLK_1) | PCLK1_SYSCON(PCLK_1); }
--------------------
- А мораль отсюда такова: всякому овощу свое время. Или, хочешь, я это сформулирую попроще: никогда не думай, что ты иная, чем могла бы быть иначе, чем будучи иной в тех случаях, когда иначе нельзя не быть. © Lewis Carroll. Alice's adventures in wonderland.
|