10 Replies Latest reply on Oct 21, 2014 9:13 AM by chuck.sommer

    Sporadic Failure of timer value, Bug?

    patrik.roth
              Hello together, im working with a CY8CKIT-050. Sometimes I have the problem that the timer (32 bit udb) not count correctly. (example: 962945, 962688,962942). Is seems that sometimes a byte is not captured right. I've created a test Project where you can test this (stops on breakpoint when the Counter value is not okay). I assembled a new chip (80 MHz variant), but it has the same issue. I create a case, but until now I don't get a solution. I need the timer for the project of my company. Perhaps, somebody here can help me. Thanks and regards from Germany Patro   
        • 1. Re: Sporadic Failure of timer value, Bug?
          user_14586677

          There is something I must be missing.

             

           

             

          You start a timer, running continuously, simply being clocked, then

             

          in a non deterministic loop keep reading it and get different values.

             

          Thats normal ! The clock source is derived from a PLL, which has

             

          jitter, the CPU is affected by other processes and asynch events.

             

           

             

          If you are trying to measure an unknown inputs period you would

             

          use a gate and run the timer during the gate, and stop it at end of gate

             

          and read it.

             

           

             

          Regards, Dana.

          • 2. Re: Sporadic Failure of timer value, Bug?
            user_1377889

            Workaround:

               

            TIMER_Stop();
            time = TIMER_ReadCounter();
            TIMER_Start();

               

             

               

            I ran your program on a PSoC4 and there was a discrepancy, too. Although it is a bit unusual to continously read the counter-value.

               

             

               

            Bob

            • 3. Re: Sporadic Failure of timer value, Bug?
              content.librarian
                      Hi together, thank you for your suggestions. I'm not reading the timer continuously in my normal program. I write this program only to simulate/ force the error which I get in my normal program sometimes. The clocks are synch, and the capture function of the datapath capture the values in the fifos. The Counter value is read from the fifos not from the Count register. Someone else have the same problem: http://www.cypress.com/?app=forum&id=2232&rID=77745 Thank you for the Workaround, it works. But it seems to me, that the capture to fifo function with synch not work properly.   
              • 4. Re: Sporadic Failure of timer value, Bug?
                patrik.roth
                        If somebody has the same problem, here is the solution: (void)(* (reg8 *) TIMER_TimerUDB_sT32_timerdp_u0__A0_REG); must be called in the ReadCounter function, instead of (void)(* (reg32 *) TIMER_TimerUDB_sT32_timerdp_u0__A0_REG);   
                • 5. Re: Sporadic Failure of timer value, Bug?
                  user_1377889

                  A wrong type cast? I've never thought of something like that!

                     

                  Are you going to file a MyCase to inform Cypress so that this can be corrected for everyone?

                     

                   

                     

                  Bob

                  • 6. Re: Sporadic Failure of timer value, Bug?
                    patrik.roth
                            Hi, cypress found the solution after i've created a case , so they are informed. Regards, Patrik   
                    • 7. Re: Sporadic Failure of timer value, Bug?
                      chuck.sommer

                      Hi, I ran into this bug back in early march 2014 and got my local FAE involved. 

                         

                      I was advised this problem was introduced with version 2.40 of the Timer component and also exists in version 2.50. 

                         

                      (Note: versions 2.40 and 2.50 were in PSoC Creator 3.0 Component Pack 7)

                         

                      2.40 was when the MISRA compliance was added to the component.

                         

                      I was very much supprised and dissapointed when the fix to this bug was NOT included in PSoC Creator 3.0 SP1

                         

                      Below is the code generated for version 2.30 of the component, The line in question is:

                         

                           CY_GET_REG8(Timer_REAL_TIME_COUNTER_1MHz_COUNTER_LSB_PTR); // correct version

                         

                      /*******************************************************************************
                      * Function Name: Timer_REAL_TIME_COUNTER_1MHz_ReadCounter
                      ********************************************************************************
                      *
                      * Summary:
                      *  This function returns the current counter value.
                      *
                      * Parameters:
                      *  void
                      *
                      * Return:
                      *  Present compare value.
                      *
                      *******************************************************************************/
                      uint32 Timer_REAL_TIME_COUNTER_1MHz_ReadCounter(void)
                      {

                          /* Force capture by reading Accumulator */
                          /* Must first do a software capture to be able to read the counter */
                          /* It is up to the user code to make sure there isn't already captured data in the FIFO */
                          CY_GET_REG8(Timer_REAL_TIME_COUNTER_1MHz_COUNTER_LSB_PTR);

                          /* Read the data from the FIFO (or capture register for Fixed Function)*/
                          return (CY_GET_REG32(Timer_REAL_TIME_COUNTER_1MHz_CAPTURE_LSB_PTR));
                      }

                         

                      Below is the code generated for version 2.30 of the component, the line in question is:

                         

                               (void)Timer_1_COUNTER_LSB;

                         

                      /*******************************************************************************
                      * Function Name: Timer_1_ReadCounter
                      ********************************************************************************
                      *
                      * Summary:
                      *  This function returns the current counter value.
                      *
                      * Parameters:
                      *  void
                      *
                      * Return:
                      *  Present compare value.
                      *
                      *******************************************************************************/
                      uint32 Timer_1_ReadCounter(void)
                      {

                          /* Force capture by reading Accumulator */
                          /* Must first do a software capture to be able to read the counter */
                          /* It is up to the user code to make sure there isn't already captured data in the FIFO */
                          (void)Timer_1_COUNTER_LSB;

                          /* Read the data from the FIFO (or capture register for Fixed Function)*/
                          #if(Timer_1_UsingFixedFunction)
                              return ((uint32)CY_GET_REG16(Timer_1_CAPTURE_LSB_PTR));
                          #else
                              return (CY_GET_REG24(Timer_1_CAPTURE_LSB_PTR));
                          #endif /* (Timer_1_UsingFixedFunction) */
                      }

                         

                      Also note, this same problem exists with the function

                         

                      void Timer_1_SoftwareCapture(void)

                         

                       

                         

                       

                         


                       

                      • 8. Re: Sporadic Failure of timer value, Bug?
                        chuck.sommer

                        OOPs correction to my previous post (a little one)

                           

                        The instance of the Timer component "Timer_1" was based on version 2.50 of the Timer component (not 2.30 as I reported)

                        • 9. Re: Sporadic Failure of timer value, Bug?
                          chuck.sommer

                          OOPs, reread what I wrote, and wish to add to it.

                             

                           

                             

                          This problem does NOT exist in version 2.30 of the component, so my solution was to use this older version of the component in my design.  I did NOT follow up what features I am loosing by using this older component.

                             

                           

                             

                          Chuck

                          • 10. Re: Sporadic Failure of timer value, Bug?
                            chuck.sommer
                                    PSoC Creator 3.0 SP2 has fixed the problem in with Timer_ReadCounter() But the problem was not fixed in the function: Timer_SoftwareCapture()   
                            • 11. Re: Sporadic Failure of timer value, Bug?
                              chuck.sommer
                                      For rev 2.60 of the Timer Component