Clarification for timer restart

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

cross mob
DaHu_285096
Level 5
Level 5
10 likes received 250 replies posted 100 replies posted

 From what I understand, the Timer component will reload the period register everytime it gets to 0.

   

Can I simply write the count = 0 to force the timer to start over ?

   

For example, I want to add a timeout to a serial rx routine...

   

CY_ISR(mytimerint){

   

  Timer_ReadeStatusRegister(); //clear interrupt

   

  timeout = 1;

   

}

   

 

   

in my routine.........

   

timeout = 0;

   

Timer_WriteCounter(0);

   

while(!timeout){

   

  //do my stuff

   

}

0 Likes
4 Replies
DaHu_285096
Level 5
Level 5
10 likes received 250 replies posted 100 replies posted

 Looking through previous posts, I note this issue of being able to reset the timer to form non-blocking version of CyDelay come sup time and again.

   

Has Cypress not come up with a non-blocking timer function yet? It seems to me that dropping down components and using control components and logic levels simply to get a non-blocking timeout funtion is convoluted.

   

It appears in my previous post, I would also need to stop the timer before setting counter value and then restart. So, to get a simple non-blocking timeout function I need to set up a volatile flag, create a timer interrupt that sets the flag and clears the interrupt then in code. I need to place a Timer, Low digital level, Clock and isr on the work sheet and then in the main code have to stop the timer, set counter value to 0, reset the timeout flag and start the time again.

   

Something real simple like below would seem more convenient to me...

   

CyTimeout(100);

   

While(!CyTimedOut){

   

//do stuff

   

}

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Yes, you are quite right. This is the exactly the code I used for my own. I'm afraid Cypress cannot provide us with every solution, some we have to do ourselves. You may of course write your own timer/timeout components and use them where required.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

A HW reset via control reg would be an option .....

   

 

   

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I prefer the good ol' software solution...

   

You may even set the clock to MHz and get µs resolution

   

Example was compiled using Creator 3.1 beta release and a Pioneer BLE kit.

   

 

   

Bob

0 Likes