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 having an issue with using a One-Shot Timer as a serial message timeout. I have a RS232 serial device I'm communicating with via the PSoC and I need to detect end of transmission and echo the transmission back to a host PC. Unfortunately there is no delimiter character of any kind from the device that I can use to know when a transmission is done, so I'm stuck using a timeout.
The device is 2400 Baud, so I have configured a 10mS One-Shot mode timer as my timeout. I want to Reload/Restart the timer when a character is received, and when I hit the timer ISR, I know the transmission is done.
According to the datasheet, calling Timer_Stop() should reload the period value into the timer when operating in One-Shot. This does not appear to be happening as it should.
I have a scope capture of the serial data alongside when the timer ISR is firing (Blue toggles when Timer ISR fires). The cursors are placed where the timer in theory should be starting (10mS before the ISR fires):
Here's the code for the relevant ISRs. Note that file-scope globals (DV_CharIndex and DV_UART_MsgDone) are both declared as volatile, and the UART RX ISR has a higher priority than the Timer ISR:
UART RX ISR:
* - Fires when character received at DV_UART
* - Reads any received characters into next buffer location(s)
* - Starts timer to determine end of message (see Message Timer ISR)
So I'm a little confused as to why this isn't working properly. The timer doesn't appear to be resetting on the Stop/WriteCounter calls as evidenced by the timer ISR firing in the middle of a transmission. I'm a little stumped as to why this isn't working the way I'm expecting.
Anyone have any thoughts? Thanks in advance!
[EDIT] I should also note that I am not actually talking to the device in question, but simulating expected behavior through a test rig. I am sending a command via DV_UART_TX (DV_UART_PutString()) and have a loopback cable connected that directs it right back into DV_UART_RX. I don't think that should cause an issue, but it's worth mentioning. The expected behavior is very similar to what I'm simulating. I send a command to the device, it echoes back the command plus some extra data bytes. Only real difference should be that it will take longer to get serial data back in production than when I'm using the loopback.