Data loss during multiple UARTs communication S12G128

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Data loss during multiple UARTs communication S12G128

Jump to solution
789 Views
walter_wang
Contributor III

My design is based on S12G128 running at 24M bus clock, and 2 SCI ports are used, 1 of them for downlink communication and another for uplink communication, so it looks like a serial communication bridge.

I'm using CW 5.1 and processor Expert, downlink SCI is configured to 115200 baud and uplink SCI is 19200 baud, both of them are interrupt-enabled and assigned some TX/RX buffer in PE panel.

Uplink received message handling is done in uplink_OnRxChar event, in this event the incomming char is checked and stored to an private buffer, when char count reaches to 5, means a command frame is received, after analysis the frame, a 64-bytes response is sent by calling SendBlock function.

My finding is there are possibility of downlink data loss, especially in downlink RX. By insert GPIO-toggle actions and measuring by oscilloscope, I found calling SendBlock() for 64-bytes will cost around 200~300uS time, this probally causes my problem, because in uplink_OnRxChar event, other interrupt is prohibited unless event/interrupt completed, so during the 200~300uS, probably multiple downlink RX interrupts happened due to high baudrate 115200, but only last one can be served after uplink_OnRxChar event completed.

To resolve the issue, I have to re-enable interrupt before calling SendBlock() by calling __EI() to allow downlink RX interrupt, so downlink RX looks OK, but unfortunately another problem pop up: uplink only TX 63 bytes even I'm calling SendBlock() to transfer 64 bytes.

 

I'm wondering, can I re-enble interrupt in uplink_OnRxChar event? Can I call SendBlock() in interrupt event? Will this cause un-predictable problem?

 

Thanks.

Labels (1)
1 Solution
530 Views
RadekS
NXP Employee
NXP Employee

Hi Wang,

As first I would like to note that processing any I/O function inside interrupt routine is generally a bad idea.

It started work only due to interrupt nesting feature and your luck that your uplink SCI probably have higher priority.

The interrupt nesting feature is great tool how to prioritize your interrupts, but I am not sure whether generated PE code suppose using it.

Do you know which character missing (first or last)?

 

The general recommendation is using RX interrupt routine just for flag signalization and service TX sending functions somewhere inside main loop. In that case, both RX and TX streams may be handled by interrupt routines “simultaneously”.

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

4 Replies
531 Views
RadekS
NXP Employee
NXP Employee

Hi Wang,

As first I would like to note that processing any I/O function inside interrupt routine is generally a bad idea.

It started work only due to interrupt nesting feature and your luck that your uplink SCI probably have higher priority.

The interrupt nesting feature is great tool how to prioritize your interrupts, but I am not sure whether generated PE code suppose using it.

Do you know which character missing (first or last)?

 

The general recommendation is using RX interrupt routine just for flag signalization and service TX sending functions somewhere inside main loop. In that case, both RX and TX streams may be handled by interrupt routines “simultaneously”.

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

530 Views
walter_wang
Contributor III

Hi Radek,

BTW, why I cannot find the Correct Answer button of your reply?

0 Kudos
530 Views
RadekS
NXP Employee
NXP Employee

Hi Wang,

I am sorry, the note about “Correct Answer button” is just automatic text attached to my signature. If fact, it is related only to question type threads. You created the discussion thread, therefore Correct Answer button is not available in this case. You may simply ignore this note for discussion threads.

 

I just converted your discussion thread into question thread. So, the Correct Answer button should be available from now.

BR

Radek

0 Kudos
530 Views
walter_wang
Contributor III

Dear Radek,

Got it, thanks. Maybe I need to move TX codes out of interrupt. 

Walter

20161120

0 Kudos