UDB Counter and counter register read operation | Cypress Semiconductor
UDB Counter and counter register read operation
I am using a PSoC3 device where I placed a 16 bit UDB up/down counter, with count and direction HW inputs.
Period is 65534 (MAX). I am not using any HW output from this counter, but, while clock input is connected to bus clock, count input is connected XORed with value from input pin and a register bit used to change count sensitive edge (double sync on each pin, about 200-400Hz).
While counting, I am polling counter using Counter_ReadCounter() function.
From time to time, I am getting incorrect values from this function. This is one example of my output log from serial communication:
Polling counter in down count from 1823. Once near 769 (I can see the whole log sequence that counted correctly without issues), I get once 512, then back 741 on next poll, that happens after some time (without changing counter direction, the device is detecting condition and stopping operation due to unexpected count value, than is showing status).
This is just one example of what is happening, and it seems issue is quite random, but it is very hard to reproduce in my code.
At this point, my code is quite large; I should consider trying with a smaller example that aims to reproduce the issue, but first I am trying to ask if there is anything I am doing wrong or if I should use a different approach to read FIFO of UDB counter, or if there is any known issue related to this counter.