Hi
I'm using Teensy 3.2 and we're doing a long term project with teensy.
We've recently come across a situation that's not handled by the Teensiduino library we use and causes de UART to stop receiving characters.
If you refer to the processor datasheet, page 1215, you will read:
Under the Overrun bit:
" If the OR flag is set, no data is stored
in the data buffer even if sufficient room exists. Additionally, while the OR flag is set, the RDRF and IDLE
flags are blocked from asserting, that is, transition from an inactive to an active state. "
For the Framing Error bit:
" FE inhibits further data reception until it is cleared.
To clear FE, read S1 with FE set and then read D. "
None of these cases are treated in the serialX.c file (again in the version we use).
Original code was (for Serial2.c)
Changed to (but not yet working properly):
Reusing the code that was already in place for UART_S1_RDRF | UART_S1_IDLE deals with the necessary conditions: reading the UART_S1 and reading D.
If this has alreayd been fixed in any newer version, my apologies and please disreagard this.
If this is still an issue in the urrent Teensyduino versions, you might want to check this as the UART actually stops receiving characters. A Serial.end() and Serial.begin() are required to resume reception of characters.
I have confirmed characters are sent using a Logic Analyser but the last one Teensy sees is the one immediately before occuring the Framing Error.
This is not to say that Operating with Framing Errors is a great practice; but halting the UART on such occasion isn't desirable as well.
Regards,
I'm using Teensy 3.2 and we're doing a long term project with teensy.
We've recently come across a situation that's not handled by the Teensiduino library we use and causes de UART to stop receiving characters.
If you refer to the processor datasheet, page 1215, you will read:
Under the Overrun bit:
" If the OR flag is set, no data is stored
in the data buffer even if sufficient room exists. Additionally, while the OR flag is set, the RDRF and IDLE
flags are blocked from asserting, that is, transition from an inactive to an active state. "
For the Framing Error bit:
" FE inhibits further data reception until it is cleared.
To clear FE, read S1 with FE set and then read D. "
None of these cases are treated in the serialX.c file (again in the version we use).
Original code was (for Serial2.c)
Code:
#ifdef HAS_KINETISK_UART1_FIFO
uint32_t newhead;
uint8_t avail;
if (UART_S1 & (UART_S1_RDRF | UART_S1_IDLE)) {
__disable_irq();
avail = UART1_RCFIFO;
if (avail == 0) {
Changed to (but not yet working properly):
Code:
#ifdef HAS_KINETISK_UART1_FIFO
uint32_t newhead;
uint8_t avail;
uint8_t uartreg_S1 = UART1_S1; /* read and cache */
if (uartreg_S1 & (UART_S1_RDRF | UART_S1_IDLE /* IMPORTANT, ADDED to treat: */| UART_S1_OR | UART_S1_FE)) {
__disable_irq();
/* my own internal COMM stats; these 2 lines are optional */
//if (uartreg_S1 & UART_S1_OR) b_serial2_bo_count++;
//if (uartreg_S1 & UART_S1_FE) b_serial2_fe_count++;
avail = UART1_RCFIFO;
if (avail == 0) {
Reusing the code that was already in place for UART_S1_RDRF | UART_S1_IDLE deals with the necessary conditions: reading the UART_S1 and reading D.
If this has alreayd been fixed in any newer version, my apologies and please disreagard this.
If this is still an issue in the urrent Teensyduino versions, you might want to check this as the UART actually stops receiving characters. A Serial.end() and Serial.begin() are required to resume reception of characters.
I have confirmed characters are sent using a Logic Analyser but the last one Teensy sees is the one immediately before occuring the Framing Error.
This is not to say that Operating with Framing Errors is a great practice; but halting the UART on such occasion isn't desirable as well.
Regards,
Last edited: