This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GH6PM: TM4C123 timer prescaler doesn't seem to have any effect

Part Number: TM4C123GH6PM

Hi,

I am using timer0 to generate an interrupt every 1 second. This is working fine, but now I want to use the prescaler in order to increase the interrupt period to any number of seconds. If, with no prescaler, I am getting an interrupt every 1 second, I expect that setting the prescaler to 1 I will get an interrupt every 2 seconds and so on, but this is not working.

The code where I initialize timer0:

void timer0_init(void){

    // We assume that the system clock frequency is 40MHz -> T = 25ns

    /* Enable 16/32-Bit Wide General-Purpose Timer0 clock in Clock Gating Control */
    SYSCTL_RCGCTIMER_R |= 0x01;

    /* Ensure timerA is disabled before modifying it */
    TIMER0_CTL_R &= ~0x01;

    /* Select 32-Bit configuration */
    TIMER0_CFG_R = 0x00000000;

    /* Configure timer as periodic, count down and other functionalities as needed */
    TIMER0_TAMR_R = 0x02;

    /* Load start value */
    TIMER0_TAILR_R = 0x26259ff; //40MHz -> to generate an interrupt every second, value to load: 40.000.000 - 1 = 39.999.999 -> 0x26259ff

    // PRESCALER ??? does not have any effect
    TIMER0_TAPR_R = 0xff;  // tried with different values with no effect

    /* Enable Timer0 interrupt in NVIC */
    ROM_IntEnable(INT_TIMER0A);

    /* Enable interrupt */
    TIMER0_IMR_R |= 0x01;

    /* Start counting */
    TIMER0_CTL_R |= 0x01;
}

What am I missing?

Thanks