3 Replies Latest reply on Jan 5, 2016 2:27 AM by user_388353959

    PSOC4 and encoder

    user_220409361


       I use a timer (hardware timer) to run as encoder.
      In the documentation is written that  a register that I can read off the direction of rotation of the encoder from TCPWM_CNT_STATUS register.
      I do not know how in my program, I can have access to this register.
      Can someone show me how to do it.

        • 1. Re: PSOC4 and encoder
          user_1377889

          Arek,

             

          I would suggest you not to read registers directly, but to use the appropriate APIs to get the required information. Try the TCPWM_ReadStatus() function to check if the flag is STATUS_DOWN is set, might work with the quad encoder.

             

           

             

          Bob

          • 2. Re: PSOC4 and encoder
            user_220409361

            Maybe a silly question but how can I read the register directly?

               

            which APIs function I should use to read the register TCPWM_CNT_STATUS ?

            • 3. Re: PSOC4 and encoder
              user_388353959

              @arek

                 

              Try this

                 
              uint8 direction;  direction = QuadDec_ReadStatus() & 1; /* read direction                                         bit0 = QuadDec_STATUS_DOWN                                         bit1 = QuadDec_STATUS_RUNNING                                         direction ist _STATUS_DOWN                                         see TRM PSoC 4200 S. 176 */
                 

              //QuadDec is my TCPMW Instance

                 

              Reiner