This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Clock Setup not as expected

*** Setup not as expected while debugging
Hi,

I have a simple program for PWM which I could simulate in the software but it it doesn't run on the hardware, I suspect there is something wrong with the clock selection.

I checked the clock control registers during debugging and found that they were not configured according to what I had set using the configuration wizard of the startup file. (i.e. Clock source always remained internal oscillator and PLL registers were never setup)

However as per my understanding the startup file (LPC2300.s) in the project should have established PLL.

Can someone advise what am I missing here?? Do we need to initialize clocks manually in the program?? If yes then what is the use of startup file??

Further I also tried by adding a separate clock initialization module in my code(which I copied from the web and edited as required). But while debugging whenever I reach """while( !( PLLSTAT & PLOCK ));""" the debugger gets stuck. So I don't know whether this will work on my hardware or not. Please advise asap.

void initClocks()
{ setupPLL0(); feedSeq(); //sequence for locking PLL to desired freq. connectPLL0(); feedSeq(); //sequence for connecting the PLL as system clock
} void setupPLL0(void)
{ PLLCON = 0x01; PLLCFG = 0x24; // set the multipler to 5 (i.e actually 4) CLKSRCSEL = 0x01;
}

void feedSeq(void)
{ PLLFEED = 0xAA; PLLFEED = 0x55;}

void connectPLL0(void)
{ while( !( PLLSTAT & PLOCK )); //PLOCK was defined in the starting as (1<<26) PLLCON = 0x03;}

0