timers

Hello EveryOne,

I am using LPC2368 controller I am using timer0/counter in interrupt mode initially i set the value T0MR0 register 100 as shown in following program .this timer is running at 1 MHz frequency Suppose i want to change this value at run time . What changes i should do .


void init_timer0 (void) {


T0PR = 0x0000003B;
T0MR0 = 100;

T0MCR = 0x03;
T0TCR = 1;


VICVectAddr4 = (UWORD32)tc0;
VICIntEnable = 1 << 4;
return;
}

Parents
  • No need for any "return;" at end of a function.
    A return statement is only needed if you either have a value to return, or you want to exit the function before you reach the ending brace.

    What changes to do? Well that would obviously depend on what result you want. Changing the value of the match register will change how far the timer ticks before it generates a reset and restarts from zero. By the way - are you sure you want the value 100 and not actually 99? 99 is the required value if you want a frequency of 10kHz in case the timer ticks at 1MHz.

Reply
  • No need for any "return;" at end of a function.
    A return statement is only needed if you either have a value to return, or you want to exit the function before you reach the ending brace.

    What changes to do? Well that would obviously depend on what result you want. Changing the value of the match register will change how far the timer ticks before it generates a reset and restarts from zero. By the way - are you sure you want the value 100 and not actually 99? 99 is the required value if you want a frequency of 10kHz in case the timer ticks at 1MHz.

Children
More questions in this forum