Log in

View Full Version : HSerin waits indefinetely



robertg
- 19th August 2024, 09:07
Hi,

Noted a issue with using either the HSerin or the serin command, if the pin associated RX is held low (which could occur if the RX pin is open circuit), the wait command of HSerin will wait indefinetely until the pin returns to a high state or a character is received.
Solved this by using a pull up resistor on the RX pin, but looking for a more robust solution that regardless of the state of the RX pin, the microprocessor will continue to operate.
Haven't testes this as yet but I've since found a possible way around this issue is to use check the state of PIR1.5 before executing the HSERIN command.
Any other suggestions?


Thanks,

Rob.

Ioannis
- 19th August 2024, 11:21
Software will stay in the waiting state.

Hserin will not. Also you can use the timout parameter and after a predefined time (in ms) it will jump to a label if something is wrong.

Ioannis

robertg
- 19th August 2024, 12:21
Thanks Ioannis,


My setup is as follows:
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
INTCON = 0
DEFINE HSER_CLROERR 1
HSERIN 1000,nodata,[datareceived]

If the RX input pin has held low it would not break out from waiting.
It doesn't make sense why it's not jumping out of the wait state aas the HSERIN is reading the buffer as opposed to serin is bit banging.
Anyway if you state it does break out regardless of the pin state, I'll double check my code again tomorrow morning.

Rob.

Ioannis
- 19th August 2024, 12:55
The plus in using the hardware USART instead of the software Serin/Serin2 is that it does not hang there if there is a problem in the state since the hardware reads based on an internal clock. If data is at 0 or at 1, then the data read is just nonsense.

More, the ardware USART does have 2 bytes buffer and Interrupt support.

Your code would jump to the label nodata after 1 sec, if there is no communication on the Rx line. What nodata does, I do not know. Please show your complete code.

Ioannis