PSOC4 and encoder

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ArOg_285336
Level 1
Level 1
10 sign-ins 5 questions asked 5 sign-ins


 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.

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
ArOg_285336
Level 1
Level 1
10 sign-ins 5 questions asked 5 sign-ins

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 ?

0 Likes
Anonymous
Not applicable

@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                                                         

0 Likes