Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
I'm trying to get basic project working to measure flight time between ultrasonic transmitter and receiver. I'm using the -050 psoc 5lp dev kit.
The receiver signal goes through a PGA to a comparator. The signal coming out of the PGA looks fine and the Comparator output is as expected too. The comparator output connects to the timer capture input. An interrupt is triggered on timer capture which reads capture value and shuts down the timer and comparator. The measurement I'm getting is between 480-490 microseconds but you can see on the attached oscilliscope the real time between PWM start and Comparator high is actually ~440 microseconds.
Attached program has sync component between the comparator and timer. I've also tried without sync component and with sync option on comparator. Same result for all.
I've also tried just sending a test signal to the timer input by driving a pin low-high with a delay of 400us. With the test signal I get a correct value from the timer capture and also matches oscilliscope.
The reset signal is synchronous in nature, thus needing a clock low to high transition while it is asserted. The code you use to reset with a control register will execute much too fast. Fortunately you do not need reset. You can write in your interrupt handler the starting value into the timer when it is stopped.
For the capture signal applies the same. I would suggest to use a "Pulse Converter" component which will ensure the required length of the capture input. Syncing the comparator output can be done by the component itself: configure sync and provide a clock to sync to.