Post Go back to editing

What is the best way to change a timer frequency without stopping the timer

I start out using a timer set to interrupt at 70 Hz. Then I want to adjust the timer interrupt to another value around 70 like 69.5Hz. My timer will need to adjust as a function of a commutator speed. I cannot stop the timer. Can I adjust TM0PRD while it is running?

Thanks,

Parents
  • Hi ,

    Yes ,  you could change the timer settings on the fly. All you need to do is wait for few cycles for the timer to get enabled with the original timer settings and then change the timer period and width for the following cycle. The new settings take effect after the inital timer setting cycle completes. Attached is  an example that shows this. In the example I change from 70 Hz to 50 Hz.

    Hope this is useful

    Thanks,

    Divya

    TimerExample.zip
Reply
  • Hi ,

    Yes ,  you could change the timer settings on the fly. All you need to do is wait for few cycles for the timer to get enabled with the original timer settings and then change the timer period and width for the following cycle. The new settings take effect after the inital timer setting cycle completes. Attached is  an example that shows this. In the example I change from 70 Hz to 50 Hz.

    Hope this is useful

    Thanks,

    Divya

    TimerExample.zip
Children
No Data