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.

timer doesn't count down in debug mode ccs5



Hi,


I am having trouble either getting timer0_a to count down or seeing it decrement in debug mode. I'm not sure which it is. I am new to both the  lm4f120h5qr and ccs5.

I have used these lines to configure system clock and enable the timer.

SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ| SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
TimerEnable(TIMER0_BASE, TIMER_A);


Have I missed anything in setting the timer up to count down and if not what am I doing wrong in using debug mode.
I am watching TAR and TAV but when I break they have a value of  0x000093E0 and don't change if I restart or single step.

  • Hello Michael,

    That is because the STALL bit is set in the Timer A config register by the TimerConfigure command. If you can clear the same then it shall start counting again.

    Regards
    Amit
  • Amit Ashara said:
    Hello Michael,

    That is because the STALL bit is set in the Timer A config register by the TimerConfigure command. If you can clear the same then it shall start counting again.

    Regards
    Amit

    Thank you for the quick response Amit. I tried this and it did not solve the issue. But I tried it on one of the examples included qs-rgb and learnt what effect setting this bit does. With it cleared I could see the timer continues when code is halted in debug and  then setting this bit stops the timer and it decrements by 4 counts when stepping.

    I am absolutely lost now. I have compared timer configuration and control settings with example code and mine. I have compared project properties and all looks correct. Any other ideas why the timer will not count in debug ?

    Also now I have a few other issues that have popped up. It seems like I am going backwards.

    Why would my program not halt at main when entering debug? It goes into running mode as soon as debug starts. It didn't do this before.

  • Hello Michael,

    Not sure either why it is not working the way it is expected to. Can you check by closing and reopening the register window?

    Regards
    Amit
  • Amit Ashara said:
    Hello Michael,

    Not sure either why it is not working the way it is expected to. Can you check by closing and reopening the register window?

    Regards
    Amit

    Hi Amit,


    That didn't help.

    In the end I just made a new project, copied and pasted same lines of code and includes into new main.c  and copied same paths to compiler and linker and it works. There must be some step in setting project properties that once muddled up there is no recovery?
    I tried resetting defaults and that didn't help.
    Very strange.
    I am happy about learning what the stall bit does. I would have been bewildered why the counter didn't step in even increments without this knowledge.

    best regards
    michael

  • Hello Michael,

    You are right, sometimes that may happen. I have seen some other issues where for no apparent reason a project gets corrupted and refuses to load. Renaming the project or importing it to another Workspace makes it work.

    Regards
    Amit
  • Ok I worked out finally that it is dumb to call my project timer0. It must get confused with the defines for TIMER0. As soon as I made a new project called timer_zero, everything works as it should.