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.

TM4C1294NCPDT: Can't Reset Timer Value

Part Number: TM4C1294NCPDT

I am trying to use one of the timers on a tm4c1294 in periodic count up mode. Everything works fine, except I can't seem to reset the count value.

Here is my initialization code:

    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
    TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC_UP);
    TimerEnable(TIMER1_BASE, TIMER_A);

Here is how I attempt to reset the timer:

HWREG(TIMER1_BASE + TIMER_O_TAV) = 0;

Even after I write 0 to TAV, I don't see the TAV or TAR registers getting reset to zero. They just keep counting up.

Can anyone explain how to reset the timer?

  • Hi Jo,
    Have you tried with TimerLoadSet()? Since you are in periodic mode, the TimerLoadSet() can be used to load the new value.
  • Yes, I tried TimerLoadSet() first.

    I commented out all of my code except for this one timer. All that happens now is the timer is initialized as above, and then I have a while loop with the reset code in it. If I use HWREG() it looks like it is resetting timer B, but not timer A. TimerLoadSet() has no effect.
  • Hi Jo-jo,
    Can you single step the disassembly for HWREG(TIMER1_BASE + TIMER_O_TAV) = 0 and see if proper value is loaded to the intended register? TIMER_O_TAV is supposed to be at offset 0x50 and TIMER_O_TBV is at 0x54. Please also watch the registers from the register browser window.
  • I'm a little rusty when it comes to ARM assembly, but it looks OK. The last instruction is STR r0, [r1]. r0 had a value of 0x0, and r1 is 0x40031050, which is the timer 1 TAV register.

    I have been watching the registers. When I step over the STR instruction, TAV ends up with a value of 0x0317B235. It isn't always that value, of course, it just looks like it's still running. TBV ends up with 0x31A, which might be right since the clock is running so fast it could have counted that high before the debugger paused.
  • HI,
    I believe you have configure for 32-bit mode. When in 32-bit mode the upper 16-bits corresponds to the GPTMTBV. If you look at the upper 16-bits from the TAV register it is 0x317 and TBV you read is 0x31A after some increments.

    Do you see the GPTMTAR changed after the GPTMTAV is written? When GPTMTAV is written, the value is loaded into the GPTMTAR register in the next clock cycle.

    Is it possible for you to operate in 16-bit mode? I'd like to know if 16-bit mode creates different result.
  • I changed the TimerConfigure() call to the following:

    TimerConfigure(TIMER1_BASE, TIMER_CFG_A_PERIODIC_UP);

    I believe this puts me in 16-bit mode. It still acts the same way though.
  • I expected to be able to see the register being cleared, and then when I saw TBV register changing too, I thought something must be wrong. Now that you pointed out how TBR and TAR are connected, I'm thinking maybe it is working properly after all. I guess there is just lag in the debugger that I didn't expect.

    Thanks for the help.
  • Hi Jo-jo,

     Glad it is clear to you now. Just wanted to comment on the 16-bit mode configuration. You will need to configure as follows for 16-bit mode using the TIMER_A for periodic count up. 

    TimerConfigure(TIMER1_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC_UP);