1 2 3 Previous Next 31 Replies Latest reply on Nov 1, 2017 12:08 PM by christian.liebhardt_1922061 Go to original post
      • 15. Re: Fix Function Timer Component help
        user_14586677

        @yfs, scratching is not enough for me, I am going to put my head

           

        into a log splitter, I am sure that will feel so much better. :)

           

         

           

        I used both a timer and a counter, in one shot mode, and nothing I tried

           

        would get them restarted with the below code. The status reg sees the first

           

        Tc and then never again. Operated in sticky mode. The control reg in pulse

           

        mode. Code gets once inside if statement, then never again.

           

         

           

        As the original poster stated, a timer/counter in one shot mode should

           

        not have to be stopped, powered down. And what gives with the status

           

        reg......The D and the pins for debugging.

           

         

           

        int main()
        {
            /* Place your initialization/startup code here (e.g. MyInst_Start()) */
           
            Counter1_Start( );



            /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */
            for(;;)
            {
                /* Place your application code here. */
               
                if ( CounterStat_Read( ) == 1 ) {                       // One shot Counter finished ?
                   
                    CyDelay( 10 );                                      // Wait 10 mS and then retrigger Counter
                    TrigCounter_Write( 0x01 );                          // Reset Counter

                }
            }
        }
         

           

         

        • 16. Re: Fix Function Timer Component help
          user_1377889

          The reset signal "...requires at least one rising edge of the clock to implement the resets of the counter value and the capture counter." (from timer datasheet) This may not be guaranteed to be fulfilled.

             

           

             

          Bob

          • 17. Re: Fix Function Timer Component help
            user_14586677

            The reset shown is way oversampled, so should happen.

               

             

               

            Still at a loss.

               

             

               

            Regards, Dana.

            • 18. Re: Fix Function Timer Component help
              user_352784942

              Hello All,

                 

              I'm getting blurry eyed looking at the possible permutations.  So what if any conclusions can be made?  It appears to me that the one shot option of the FF timer component is hosed.  I have tried this six ways to Sunday and can't make it work.   I have submitted a case on this and hopefully Cypress is reading this thread (a link was provided in the case). 

                 

              When I have more time I will come back to this issue but for now I have a  crude timer that uses a clock attached to a status register.   Part of the program cycles through reading the status resister and if there is a clock pulse active, a counter is incremented.   Based on before and after counters,  I know how many milliseconds have passed between times when the status register is read.  

                 

              Thanks again everyone for taking an interest in this issue.

                 

              Ron

              • 19. Re: Fix Function Timer Component help
                user_1377889

                @Dana

                   

                "The reset shown is way oversampled, so should happen." This I cannot deduct from the provided picture, the output setting of the control register and the write sequence could be so tight that the pulse is missed.

                   

                 

                   

                Bob

                • 20. Re: Fix Function Timer Component help
                  user_14586677

                  You are right Bob, reset input is not edge detect, its sampled by the clock.

                     

                   

                     

                  Lets see if that works.

                     

                   

                     

                  Regards, Dana.

                  • 21. Re: Fix Function Timer Component help
                    MarkS_11

                    I could be wrong but I think you have a 24MHz pulse resetting a 2.4MHz counter. The counter does not see the reset. I removed the BUS_CLK that was driving the TrigCounter register and wired the Counter_Clock to the register instead. It resets with wild abandon for me!

                       

                    This is probably too much fun during office hours...!

                       

                    -- Mark.

                    • 22. Re: Fix Function Timer Component help
                      user_352784942

                      Hello,

                         

                      I thought I would come back and pass along a solution Cypress provided.  The attached project does work and has been adapted to my particular hardware configuration.   One thing that Cypress did not mention and was determined while I was testing the solution is that the timer component apparently has a clock frequency lower limit.  With a clock running at a frequency below the limit the timer component appears to experience timing issues and will not set its status register properly.  I really don't know what the lower limit is, but can tell you that a 1KHz clock frequency will not work.  The solution Cypress provided had a 50KHz clock and I was able to move down to a 15KHz clock.  

                         

                      Also you will notice another timing issue with the timer component.  A call to CyDelayUs is required after setting the control register bit to reset the timer.  I have found the value for CyDelayUs can be set as low as 10us.  Anything below that the timer component misses the reset.  The call to CyDelayUs might be able to be removed if the control register bit is set to "PulseMode" but I have not tested that.

                         

                      Regards,

                         

                      Ron

                      • 23. Re: Fix Function Timer Component help
                        user_352784942

                        Hi Again,

                           

                        OK, attached is the same solution but using a control register bit set to "PulseMode" .   This eliminates the need for a call to CyDelayUs. 

                           

                        Cheers,

                           

                        Ron

                        • 24. Re: Fix Function Timer Component help
                          user_1377889

                          There is a condition required for the correct functioning of the one-shot reset: The reset pulse has to be so long that the timer "sees" at least one rising edge of the clock (stated in datasheet).

                             

                          Since your controll register is asynchron to the timer clock it is difficult to fulfill this condition. You use a delay of 100µs and feed the timer with 15kHz which is 66µs => that will work. But when you lower the input frequency to 10kHz the reset will start to fail from time to time.

                             

                          A way out as you already suggested is to use a pulsed control register output with a clock at least with the input clock. better would be to divide it with a t-FF.

                             

                           

                             

                          Bob

                          • 25. Re: Fix Function Timer Component help
                            user_1377889

                            We got a tough timing with our posts,too !

                               

                             

                               

                            Bob

                            • 26. Re: Fix Function Timer Component help
                              user_352784942

                              Hi Bob,

                                 

                              I can see clearly now the rain is gone .   These timing issues were presented in this thread but I just was not catching on.  Yes, there is a direct relationship between the timer component input clock and reset pulse width.  This comes under the category of being "thick as a brick".   But I'm on my way now. 

                                 

                              Thanks to you and all,

                                 

                              Ron

                              • 27. Re: Fix Function Timer Component help
                                user_1377889

                                Be sure: You're not the first having that issue... and probably not the last.

                                   

                                 

                                   

                                Bob

                                • 28. Re: Fix Function Timer Component help
                                  user_352784942

                                  Hi Bob,

                                     

                                  One last post regarding the timer component.  The timer component solution has been successfully integrated into the "real" application.  Bob,  I did incorporate the t-ff . and the timer is working flawlessly providing accurate "timer expired" results. 

                                     

                                   

                                     

                                  Thanks to all,

                                     

                                  Ron

                                  • 29. Re: Fix Function Timer Component help
                                    user_1377889

                                    Thank you for keeping us informed!

                                       

                                     

                                       

                                    Bob