This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28379D: Request for details on SCI error handling

Part Number: TMS320F28379D

Hi

I would like to request some more details on how thew SCI on a f28379d will handle error situations.

There is a lot of questions in this post, so please read carefully, and fell free to divide your answer in multiple replies.

I am limiting this question to the receiver part (RX), and also limit to cases using the FIFO.

First chapter is the different error status bits

 I have seen other posts on this topic, but i am note sure on the conclusion.

There are three registers with error status bits

  • SCIRXST
    • RXERROR  (FE|OE|PE)
    • BRKDT (not always an error but I include it here anyway)
    • FE
    • OE
    • PE
  • SCIRXBUF
    • SCIFFFE
    • SCIFFPE
  • SCIFFRX
    • RXFFOVF

I do understand what the different error types is i.e. framing error is basically a missing stop bit a.s.o.

What is unclear is the behavior and relationship between SCIRXST->FE and SCIRXBUF->SCIFFFE.

Same for SCIRXST->PE and SCIRXBUF->SCIFFPE

Let me explain how I do understand this, and then please correct me where I am wrong.

lets imagine the SCI has received 5 bytes of data, all stored in the fifo.

We name these bytes b0 to b4, where b0 is the first to arrive on the serial line, and thus first in the fifo.

When the SCI recieved b2 it detected an parity error.

Now as I understand this.

  • At the moment where b2 was received and the parity error detected, the SCIRXST->PE bit will be set, and an error IRQ will be triggered if enabled.
  • The SCIRXST->PE bit will remain set until the SW issues a SW reset, by writing a 0 to the SCICTL1->SWRESET bit, followed by writing a 1 to the same bit.
  • In the FIFO there is room to store this information, so the parity error is stored alongside the byte.
  • When reading the bytes from the FIFO, by reading the SCIRXBUF register, I get the SCIFFPE bit as being set when, and only when, I read the b2
    • As these registers is not mentioned in the to SWRESET description, I assume the error information stored in the FIFO is not affected by a sw-reset.

So after 5 reads of the SCIRXBUF register this is what i got out:

byte

bit 15

SCIFFFE

bit 14

SCIFFPE

bit 13-8

RESERVED

bit 7-0

SAR

b0 0 0 x

data

b1 0 0 x data
b2 0 1 x invalid data
b3 0 0 x data
b4 0 0 x data
  • sidenote: Also to my understanding I have to read the SCIFFPE and the SAR, in one read, as an attempt to read only the SCIFFPE, would count as a read of that register, and pop the next value from the FIFO.

This all means that I can conclude that b0 and b1 is valid data as they where received before the error, as for b3 and b4, as they where received after the error it very much depends on other factors if they are valid, but no error was detected during the reception of those.

Now on to the next chapter of my question, data during and error.

Here i am thinking of what is shifted into the RXSHF register, and what will later turn up in the SCIRXBUF, under different error scenarios.

  • On parity error I expect the received bits to be there, just marked bad by the parity error bit.
  • On framing error, I expect the same, so in the case where a high->low transitions on the line, triggered the read, but the line came up again, thus no stop bit, I would se zerros in the SAR.
    • if you now look at the content of RXSHF (i know it's not accessible from SW) , of all zeros including the parity, depending on parity setting this can be detected as a parity error. Will this also result in a setting of the parity error bit, or is it excluded by the framing error?
  • On break detect from the manual "A break condition occurs when the SCI receiver data line (SCIRXD) remains continuously low for at least ten bits, beginning after a missing first stop bit"
    • Will this "missing first stop bit" trigger a framing error, or is this excluded by the break detection?
    • Again from the manual "The occurrence of a break <cut> but it does not cause the receiver buffer to be loaded.", Partly depending on the answer to the previous question. will the data before the "missing first stop bit" be shifted, and thus change RXFFST?

Last chapter, Misbehaving SW.

SW sometimes behaves different than the designers of the SCI expected :-)

How hard isthe shifting of the data from the RX-pin connected to the CTL registers et. all. ?

if the SWRESET bit or the RXENA bit is changes by SW in the middle of recieving a byte.

  • will the shifting into RXSHF stop imidially?
    • if no, will it be pushed to SCIRXBUF?
    • if yes, will the bits already received be pushed, and will this potentially result in parity or framiong error being detected?

Are there any way besides the ones above, where misbehaving SW can trigger false PE/OE/FE errors?

If I want to change a setting like the parity bit. after first communication (cannot guarantee a silent line), what is then the recommended procedure?

Yes I do assume it involves clearing the RXENA bit, but

  • Do I need to wait for anything, like shifting of a potential byte being received during the change?
  • Do I need to empty the FIFO, and if I don't will the current data in the FIFO be reinterpreted, i.e. if I change the data size or parity setting?

When issuing a sw-reset, by writing a 0, followed by a write of 1 to SWRESET. Do i need to insert a pause between the write of 0 and 1?

NB: there is a typo in the reference manual "SPRUHM8I–December 2013–Revised September 2019", page 2295, line 4
"SCIFFTX controls the receive FIFO interrupt" i think it should be "SCIFFRX controls the receive FIFO interrupt"

  • Hi Martin,

    Thank you for your post. I need some time to go through all of your questions in detail. Please expect my initial response before the end of the week. Note, some of the items you asked about may require some input from our design team, in which case it may take longer to provide you with an answer. Therefore, please let me know if any of these questions are urgent for you and we can prioritize accordingly.

    Best Regards,

    Marlyn

  • Hi Martin,

    Let me explain how I do understand this, and then please correct me where I am wrong.

    The way you interpreted the information is correct. 'SCIFFFE' and 'SCIFFPE' bits within the RXBUF register are meant to serve as flags for the specific set of data being received. The 'FE' and 'PE' bits within the SCIRXST register can be thought off as high level error flags where the flags will get set if any data that is received has a framing or parity error.

    On parity error I expect the received bits to be there, just marked bad by the parity error bit.

    This is correct.

    On framing error, I expect the same, so in the case where a high->low transitions on the line, triggered the read, but the line came up again, thus no stop bit, I would se zerros in the SAR.
    • if you now look at the content of RXSHF (i know it's not accessible from SW) , of all zeros including the parity, depending on parity setting this can be detected as a parity error. Will this also result in a setting of the parity error bit, or is it excluded by the framing error?

    The detection mechanism is independent of both so flagging a framing error will not exclude the detection of a parity error. If there is a parity and framing error then both flags will be set.

    On break detect from the manual "A break condition occurs when the SCI receiver data line (SCIRXD) remains continuously low for at least ten bits, beginning after a missing first stop bit"
    • Will this "missing first stop bit" trigger a framing error, or is this excluded by the break detection?
    • Again from the manual "The occurrence of a break <cut> but it does not cause the receiver buffer to be loaded.", Partly depending on the answer to the previous question. will the data before the "missing first stop bit" be shifted, and thus change RXFFST?

    In all circumstances, they are independently detected and will not prevent each other from being set. So you will have a framing error and a break detect error. Note, if you are checking if SCIRX is suddenly driven low by some SCITX by mistake, then checking the break detect flag is better than the framing error flag. The advantage of BRKDT compared to FE is that it can get detected by SCIRX and fire an interrupt to SW even if it is sleeping in multiprocessor SCI mode usage. Sleeping SCIRX will only wakeup if it detects address bit as “1” but if address bit is also “0” , it will not wakeup the sleeping RX. In such a case BRKDT only can fire as FE will not help in identifying such stuck at “0” issues.

    Data before the missing first stop bit will still be shifted through. Whenever a start bit is detected, the SCI will still receive the data and set errors accordingly if there are any. Its all dependent on the location of the start bit.

    if the SWRESET bit or the RXENA bit is changes by SW in the middle of recieving a byte.

    • will the shifting into RXSHF stop imidially?
      • if no, will it be pushed to SCIRXBUF?
      • if yes, will the bits already received be pushed, and will this potentially result in parity or framiong error being detected?

    RXENA is in charge of shifting the data into the RX buffer. Data will still be received in the RXSHF register just not shifted into the RX buffer if the RXENA bit is cleared during the middle of receiving a byte. From the TRM, "Data continues to be assembled in RXSHF but is not transferred to the receiver buffer register." Also, once the SCI receives a complete frame then it transfers the data in the RXSHF register to the SCIRXBUF register. 

    A change in SWRESET during the middle of bit reception shouldn't affect the reception of the data.

    Are there any way besides the ones above, where misbehaving SW can trigger false PE/OE/FE errors?

    Yes, please refer to this thread for greater details (specifically Vince's response marked as "TI Thinks Resolved": TMS320F280025: SCI communications byte timing - C2000 microcontrollers forum - C2000Tm︎ microcontrollers - TI E2E support forums

    The important things to take away is making sure that you are using 2 stop bits and that you make the RX interrupt as short as possible. 

    If I want to change a setting like the parity bit. after first communication (cannot guarantee a silent line), what is then the recommended procedure?

    This is system dependent (there is no limitation on hardware for when this needs to be changed).

    Yes I do assume it involves clearing the RXENA bit, but

    • Do I need to wait for anything, like shifting of a potential byte being received during the change?
    • Do I need to empty the FIFO, and if I don't will the current data in the FIFO be reinterpreted, i.e. if I change the data size or parity setting?

    Once its in the FIFO, the RX error will occur (if there are any). The SCI module will not reinterpret the data with the new parity or other settings that may have changed. Therefore, after you change a parameter, you should clear the FIFO data or acknowledge in your system that there will most likely be errors in the data caused by the change.  

    When issuing a sw-reset, by writing a 0, followed by a write of 1 to SWRESET. Do i need to insert a pause between the write of 0 and 1?

    There is no requirement for the amount of time you need to wait between SWRESET writes.

    NB: there is a typo in the reference manual "SPRUHM8I–December 2013–Revised September 2019", page 2295, line 4
    "SCIFFTX controls the receive FIFO interrupt" i think it should be "SCIFFRX controls the receive FIFO interrupt"

    Thank you! We will correct this in the next revision of the document. 

    Please let me know if you have any further questions. The TX side also works very similar to the RX side. The logic is mostly mirrored across the two. 

    Best Regards,

    Marlyn

  • I marked it as resolved as you answered all my questions, but I have one follow up question that i forgot.

    It is about the interrupt triggering.

    Currently I have a setup where we utilize the FIFO, but RXFFIL is set to 1, so we get an interrupt as soon an one byte is received.

     I have a IRQ service function similar to the one you find in most of the examples, first i check for errors, then i loop over the fifobuffer (using RXFFST) reading all the data out of it. And finally clear the interrupt flag.

    What happens if the end of a byte/frame is received in the short time period from my lat read of the RXFFST and until i clear the interrupt flag.

    • Will it trigger a new interrupt immediately?
    • Does the text in the TRM "The receive FIFO generates an interrupt whenever the FIFO status bits (RXFFST4-0) are greater than or equal to", mean that I only get an interrupt when next byte/frame is received and RXFFST is ==2?
  • Hi Martin,

    Will it trigger a new interrupt immediately?

    Yes, because you haven't read the new data from the FIFO in this case, a new interrupt would be triggered and the flag would remain set until you read the data/clear the interrupt flag.

    Does the text in the TRM "The receive FIFO generates an interrupt whenever the FIFO status bits (RXFFST4-0) are greater than or equal to", mean that I only get an interrupt when next byte/frame is received and RXFFST is ==2?

    Since your RXFFIL is set to 1, then an interrupt will occur as soon as you have one word in the RX FIFO or more than one word.

    Best Regards,

    Marlyn 

  • Yes, because you haven't read the new data from the FIFO in this case, a new interrupt would be triggered and the flag would remain set until you read the data/clear the interrupt flag.

    Not sure my question was clear enough, let me ilustrate.

    Here is a very simplified snippet from the IRQ service function

    As i try to illustrate, I am talking about the short time span from when RXFFST is read, and until the interrupt flag is cleared.

    And as you write in your reply "remain set until you read the data/clear the interrupt flag" But i do "clear the interrupt flag" on the last line!

  • Hi Martin,

    Thank you for the clarification. 

    a new interrupt would be triggered and the flag would remain set until you read the data/clear the interrupt flag

    Let me rephrase my response to make it more clear, I meant that the interrupt flag will be reset as soon as you clear the current interrupt flag. Its only until after you read that new set of data (and there is no more data to read) that there will be no more pending interrupt flags.

    In your scenario, as long as there is one word in the FIFO (RXFFST >= 1) an interrupt flag will get set and even if you clear the flag as along as that condition is true it will be set again after the clear. 

    Best Regards,

    Marlyn