#ifdef __USE_CMSIS #include "LPC17xx.h" #endif #define XTAL (12000000UL) /* Oscillator frequency */ #define OSC_CLK ( XTAL) /* Main oscillator frequency */ #include <cr_section_macros.h> // TODO: insert other include files here // TODO: insert other definitions and declarations here int SystemFrequency; void setclk(void){ LPC_SC->SCS = 0x20; while ((LPC_SC->SCS & (1<<6))==0); //Clkdiv, divide by 4 LPC_SC->CCLKCFG = 0x00000003; // Timer0,Uart0,PWM1,I2C0,SPI,ADC LPC_SC->PCLKSEL0 = 0x1015044; //0b01000000010101000001000100 PCLKSEL1 //External Clock LPC_SC->CLKSRCSEL = 0x00000001; LPC_SC->PLL0CFG = 0x00020033; /* MSEL0 = 51 , NSEL0 = 2 */ //Updating PLL Config LPC_SC->PLL0CON = 0x01; //Feed Sequence LPC_SC->PLL0FEED = 0xAA; LPC_SC->PLL0FEED = 0x55; //Waiting for PLL update while (!(LPC_SC->PLL0STAT & (1<<26))); //Connect PLL LPC_SC->PLL0CON = 0x03; //Feed Sequence LPC_SC->PLL0FEED = 0xAA; LPC_SC->PLL0FEED = 0x55; //Dont Used LPC_SC->USBCLKCFG = 0x00000000; //Power Control dont used LPC_SC->PCONP = 0x00000000; //LPC_SC->CLKOUTCFG = 0x000000C0; LPC_SC->FLASHCFG = (0b100)<<12; SystemFrequency = (OSC_CLK * (((2 * ((LPC_SC->PLL0STAT & 0x7FFF) + 1))) / (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1)) / ((LPC_SC->CCLKCFG & 0xFF)+ 1)); } int main(void) { // Force the counter to be placed into memory volatile static int i = 0 ; setclk(); // Enter an infinite loop, just incrementing a counter LPC_GPIO2->FIODIR = 1; LPC_GPIO2->FIOMASK = 0; while(1) { //LPC_GPIO0->DATA ^= (1<<7); LPC_GPIO2->FIOSET = 1; LPC_GPIO2->FIOCLR = 1; i++ ; } return 0 ; } |
LPC_SC->PCONP = 0x00000000; |