1 2 Previous Next 27 Replies Latest reply on Feb 25, 2015 11:30 AM by user_1377889

    PSOC1 Timer read value / ISR 16bit variable problem

    user_219011237

      Hello,

      I was struggled days for my project, but I can't either get a clue out of these problems or find a way go around of them.
      Here I post what I encountered and looking for someone else who has any thought.
       

         

      (1)

         

      When I tried to read timer values, I always got the compare values I set in the module parameters, like:

         


      Timer8_ms with a period/compare value of 99/49, when I call "Timer8_ms_bReadTimer()", I always got a constant 49 returned.

         

      Same problem occurrs when I utilitizing Timer16 module. I've tried to copy values from register like "Timer8_ms_COUNTER_REG" "Timer8_ms_COMPARE_REG" but they are all constant as well.

         

      code is like this:
          tmp_ten_us = Timer8_ms_bReadTimer();
          RTC.ten_us = 99 - tmp_ten_us;    //    converting count-down 10us value to count-up for easier human reading
          tmp_ms = Timer16_min_wReadTimer();
          RTC.ms = 59999 - tmp_ms;    //    converting count-down ms value to count-up for easier human reading

         

       

         

      (2)

         

      When ever I tried to manipulated or referencing an "unsigned int" inside an ISR--like "ms++" or "if ( ms > 999 )", the MCU hangs and I could only re-active it via setting XRES high. Is it normal, or am I missing something important?

       

         

      Any idea? Thanks.

        1 2 Previous Next