9 Replies Latest reply on Aug 23, 2014 10:34 PM by user_202683688

    Reset a timer in one shot mode




      I have a one shot timer that I want to start multiple times on my demands in software. I have the following setup


      For TopDesign see attach picture.


      The isr code:


      /* Set the flag variable */
      toggle_flag = 1;


      the main code:


      CyGlobalIntEnable; /* Uncomment this line to enable global interrupts. */


      if(toggle_flag == 1)
      toggle_flag = 0;


      But it will only goes into the isr once (because it is a one shot timer). How do I get it to go into the isr multiple time? what did I do wrong?


      An other thing in the datasheet for the timer it state the following but it does make complete sence to me can anyone explain?




      "Note In order to be sure that One Shot mode does not start prematurely, you should use a


      Trigger Mode to control the start time, or use some form of software enable mode (Software


      Only or Software and Hardware)."



        • 1. Re: Reset a timer in one shot mode

          Timer_Start() will not reset the timer! You'll need to use the reset terminal (I used additionally a control-register and toggled a bit).


          Keep in mind that the reset is NOT asynchronus, so you'll need an additional FF to sync with the input-clock.





          • 2. Re: Reset a timer in one shot mode

            Thx you.


            Before I posted this thread I did try to use a control reg with an asynchronous reset that didt work, but that didt work. I will tried you suggestion soon.

            • 3. Re: Reset a timer in one shot mode

              When you have any troubles with your project it is much easier for us to have a look at when you upload the complete project here.


              To do so:in Developer 5.2:  Build -> Clean Project


              then Zip (NOT Raw!) the complete folder and upload it here.





              • 4. Re: Reset a timer in one shot mode

                Hi mtraedholm,




                You can also try using the "Trigger Mode" as Rising edge or falling edge to trigger a shot.


                After the trigger, the component will require a reset.


                Look at the schematic below:








                You can use the Terminal Count output of the Timer and OR it with "Low" to trigger a reset after every trigger ends. Hence, your next trigger will respond again. This will eliminate the requirement of manually resetting the Timer everytime.


                To trigger, you can make a control register drive high and low (for rising or falling edge trigger). In this case, there is no necessity to use interrupt terminal, hence "Interrupt on TC" should be disabled.

                • 5. Re: Reset a timer in one shot mode
                      Dasq, your solution will work only for higher clock frequencies. When you set the clock to 1kHz the one-shot will not trigger.   
                      There are two solutions: enlarge the trigger-pulse with DFF or use for the control-register "Pulse Mode" (which is not for all silicon versions available).   
                      See attached project.   
                  • 6. Re: Reset a timer in one shot mode

                    Hi Bob,




                    Thanks for the suggestion.


                    My bad, I tested the project by using large delays (in order of ms) and it didn't mis-trigger.

                    • 7. Re: Reset a timer in one shot mode



                      Sorry to reply in old thread, but whenever we search for reset one shot timer this thread appears.


                      As Bob suggested we have control register to toggle Reset input as in project.


                      1. We have downloaded timer example which was UDB.


                      2. We changed to 16 bit fixed function.


                      3. Run mode One shot


                      4. We have used a Control reg to control Reset of timer, this control register is in "Pulse mode".


                      5. We have also used TC output to make Reset High


                      6. Reset is brought down to Low in software via setting the Contorl Register whenever you need to start again the One shot.


                      7. We tested it with 1KHz, 100KHz, 1MHz and 24MHz bus clock.


                      We used this to avoid UDB. Please comment about this approch if we are mistaken somewher.


                      Thanks in advance.

                      • 8. Re: Reset a timer in one shot mode

                        I would recommend changing this -




                        uint8 InterruptCnt;

                        uint8 Flag_If_Int=0;




                        to this -




                        uint8 volatile InterruptCnt;

                        uint8 volatile Flag_If_Int=0;




                        Regards, Dana.

                        • 9. Re: Reset a timer in one shot mode

                          Hi Dana,


                          Thanks for the valuable inputs. Yes I will correct that, please also comment on the .cysch and the method I adopted for resetting One shot timer.