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.

MSPM0L1105: MSPM0L1105 UP-DOWN COUNTER.

Part Number: MSPM0L1105
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hi Keith,

Need a timer goes up from 0 to 1sec then down 1sec to 0.

Can you provide me code.

  • Hi Harshita,

    You can configure a timer using the Sysconfig tool in CCS (or separate download) to be a periodic up/down count. This will automatically generate the initialize code for the timer. All you need to do is input which clock source you want for the timer and select the desired period.

    Here is a screen shot of two Sysconfig options to set up the timer for 1sec.  Note, because your period is long, you will need to divide the BUSCLK (32MHz) down or use the LFCLK (32kHz) clock.

  • If you want a smooth up/down for a PWM, use Dennis' advice and create a counter that has a period of 1/256 of a second. In the interrupt handler, increment a volatile variable. Once that variable gets to 255, decrement it back down to zero. You can even set the PWM of the other timer in the interrupt handler.