Content originally posted in LPCWare by expressouser on Sat Jul 12 05:29:17 MST 2014 Hi,
I am having some problem with TIMER, PCLK divider doesn't seem to work. Even if I set the pclk divider to a value different than that of the default value, it seems like the timer uses the default value.
Here is the part where I configure the timer:
pclk_tick = ((double) 1/ ( SystemFrequency/4) ) * 1000; //ms per PCLK tick. SystemFrequency is at 100MHz. // pclk_tick = ((double) 1/ ( SystemFrequency) ) * 1000; // this part doesnt work. counter = ((uint32_t) timer->interval) / pclk_tick ;//desired timer interval, in ms, in my code, this is 1.
PowerUp_Peripheral(PCTIMER0); //Set_Bit(&(LPC_SC->PCLKSEL0), 2); Clear_Bit(&(LPC_SC->PCLKSEL0), 3); //This part doesnt work. LPC_TIM0->PR = counter; //this will increment the TC everytime the timer->interval expires. LPC_TIM0->CTCR &= ~(0x3); //TIMER MODE.
and here's the part where I am 'waiting for a delay':