#include "LPC17xx.h" volatile uint32_t temp; void _delay(uint32_t del); void pllfeed() { LPC_SC->PLL0FEED=0x000000AA; LPC_SC->PLL0FEED=0x00000055; } void setpll() { uint16_t n,m,d; // the external crystal oscillator is 12 MHz // main oscillator frequency 300 MHz: M = (300 x N) / (2 x 12) n=2; m=25; // processor clock 100 MHz = 300 MHz / D d=3; // disconnect LPC_SC->PLL0CON=0x00000001; pllfeed(); // disable LPC_SC->PLL0CON=0x00000000; pllfeed(); //select the on board crystal LPC_SC->CLKSRCSEL =1; // set new PLL values LPC_SC->PLL0CFG=((n-1)<<16)|(m-1); pllfeed(); // enable LPC_SC->PLL0CON=0x00000001; pllfeed(); // set cpu clock divider LPC_SC->CCLKCFG=d-1; // wait for lock while ((LPC_SC->PLL0STAT&0x04000000)==0); // connect LPC_SC->PLL0CON=0x00000003; pllfeed(); SystemCoreClockUpdate(); } int main (void) { SystemInit(); setpll(); LPC_SC->PCONP |= ( 1 << 15 ); // power up GPIO LPC_GPIO1->FIODIR |= 1 << 29; // puts P1.29 into output mode. while(1) { LPC_GPIO1->FIOPIN |= 1 << 29; // make P1.29 high _delay( 1 << 30 ); LPC_GPIO1->FIOPIN &= ~( 1 << 29 ); // make P1.29 low _delay( 1 << 30 ); } } void _delay(uint32_t del) { uint32_t i; for(i=0;i<del;i++) temp = i; } |