Preload Timer Period

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
BRSHiFi
Level 1
Level 1
First reply posted First question asked Welcome!

Hello,

I am trying to create a delay timer that is settable before it runs. Currently, I am just executing the WritePeriod() method.

The datasheet does say that "The period of the Timer does not change until the counter is reloaded from the period register."

What is the best method to reload the counter without having the timer run once? I have the timer implemented as a fixed function, not with UDB.

Thanks

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

BRSHiFi,

Here is a very short and quick example of the Timer period reload that occurs as fast as the SW can implement.

The project has an array of different period values which changes on a SW1 press.

The Timer is in continuous mode with the same period until the SW1 press.

You are correct. My suggestion:

Timer_Stop();   /* Stop/Disable the Timer */
Timer_WritePeriod(new_period);  /* Load new period */
Timer_Enable() /*  restart the Timer with the new Period.*/

Is not sufficient for an immediate reload of the period.

According to the Timer datasheet, the reload of the period occurs on the Terminal Count (TC) or a reset.

In this project, I used a Control Register bit to strobe the reset pin of the Timer right after changing the Period.

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

0 Likes
6 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

Hi,

Try:

Timer_Stop();   /* Stop/Disable the Timer */

Timer_WritePeriod(new_period);  /* Load new period */

Timer_Enable() /*  restart the Timer with the new Period.*/

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
BRSHiFi
Level 1
Level 1
First reply posted First question asked Welcome!

It works fine the first time.

When run again with a new time, the new time does not register. It still runs with the old period.

0 Likes
BRSHiFi,
I plan to create an example project for this issue.  
Len
"Engineering is an Art. The Art of Compromise."
0 Likes
BRSHiFi
Level 1
Level 1
First reply posted First question asked Welcome!

Much appreciated.

0 Likes
lock attach
Attachments are accessible only for community members.

BRSHiFi,

Here is a very short and quick example of the Timer period reload that occurs as fast as the SW can implement.

The project has an array of different period values which changes on a SW1 press.

The Timer is in continuous mode with the same period until the SW1 press.

You are correct. My suggestion:

Timer_Stop();   /* Stop/Disable the Timer */
Timer_WritePeriod(new_period);  /* Load new period */
Timer_Enable() /*  restart the Timer with the new Period.*/

Is not sufficient for an immediate reload of the period.

According to the Timer datasheet, the reload of the period occurs on the Terminal Count (TC) or a reset.

In this project, I used a Control Register bit to strobe the reset pin of the Timer right after changing the Period.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
BRSHiFi
Level 1
Level 1
First reply posted First question asked Welcome!

Mission accomplished. That did the job.

Appreciated the help.

0 Likes