4 Replies Latest reply on Dec 27, 2014 8:21 AM by JoMe_264151

    Clarification for timer restart


       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...




        Timer_ReadeStatusRegister(); //clear interrupt


        timeout = 1;






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


      timeout = 0;






        //do my stuff



        • 1. Re: Clarification for timer restart

           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...






          //do stuff



          • 2. Re: Clarification for timer restart

            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.





            • 3. Re: Clarification for timer restart

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







              Regards, Dana.

              • 4. Re: Clarification for timer restart

                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.