2 Replies Latest reply on Feb 12, 2015 1:35 PM by user_14586677

    Timer_ReadPeriod() Bug?  Always reads 1 lower than period...

    user_385543602

       Hi,

         

      I am doing some math in a project using a timers period, and it always reads 1 less than the actual period of the timer.  See attached.  Is this a bug or am I horribly mistaken?

         

      Thank you,

         

      Tom

        • 1. Re: Timer_ReadPeriod() Bug?  Always reads 1 lower than period...
          user_1377889

          From timer datasheet pg 5

             

          Period (Software Option)
          The Period parameter defines the period of the counter. The max count value (or rollover point) for the Timer component is equal to the Period minus one. The Period minus one is the initial value loaded into the period register. The software can change this register at any time with the Timer_WritePeriod() API. To get the equivalent result using this API, the Period value from the customizer, minus one, must be used as the argument in the function.

             

           

             

          Bob

          • 2. Re: Timer_ReadPeriod() Bug?  Always reads 1 lower than period...
            user_14586677

            You are reading the period register, and that does not change unless you

               

            write to it.

               

             

               

            I think what you want is to read the actual timer value, which would be

               

            to execute Timer_ReadCounter().

               

             

               

            If you simply want to confirm what period you have set the Timer to then you

               

            do use Timer_ReadPeriod(), and as Bob mention, it is 1 less than the actual

               

            period.

               

             

               

            Regards, Dana.