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.

TMS320F28P650SH: SCI: How to check that data has been transmitted or not.

Part Number: TMS320F28P650SH
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hello Team,

I have one doubt on SCI and needs some help regarding this.

Scenerio:

There are 2 controllers (F28P6x and F2839x) in which they both are communicating over the SCI protocol.

So my design is based on half duplex it means only 1 controller is in tranmit mode and other one is in receiving mode at atime and there is in 1 EN pin in both the side which is controlling which one is master and which one is slave.

Initially I have made F28p6x (EN1 pin high )as a master and other one as a slave(EN2 pin low ).

So my queries are:

-After power cycle master sends data after that, EN1 pin we put in low mode to make a receiver, but I did not find any api which tell me that data has been transmitted successfully, if any api will be there it will be easy to take a decision to make a master and slave..

Can you please help into this.

As I am not using any Tx fifo.

Below are my sample code which I am using to transmit data.

Sysconfig SCI setting:

Api used for transmit the data:

Api used to check is data successfully transmitted or not :    (This Api is not working).

static inline bool
SCI_isTransmitterBusy(uint32_t base)

Please let me know how I can get to know that all data has been transmitted successfully.

Thank you

Shashank

  • Hi Shashank,

    Where are you calling the uart_send_data() function from? Since you have the transmit FIFO level set to interrupt when there are 16 available spots in the FIFO, I would suggest writing 16 characters at a time in this ISR. Then, when the next interrupt is triggered, you know this means all the previous characters were already transmitted out. On the receive side, you have the FIFO level set to trigger an interrupt when the FIFO is full, so in this interrupt you want to read 16 characters at a time. Once the SCI successfully reads all 16 of the characters, you know the RX FIFO is empty.

    To clarify, are you wanting to switch between states as follows:

    state 1: Device 1 transmits 16 characters to Device 2

    state 2: Device 2 transmits 16 characters to Device 1

    state 1: Device 1 transmits 16 characters to Device 2 ...

    If so, I would suggest using some global flags to keep track of the state. For example, if the flag is set as 1, write to the TX FIFO in the ISR and set the flag to 0. If the flag is set to 0, do nothing in the TX ISR. Then you can set the flag back to 1 in the RX ISR, which indicates the 16 characters have already been received.

    Let me know if this answers your question; I also apologize for my delayed response.

    Best Regards,

    Delaney

  • Hello Delaney,

    Thank you for the response.

    I am calling this function uart_send_data() in every 100ms, After calling this function I am waiting for complete transmission by using this function: while (SciaRegs.SCICTL2.bit.TXEMPTY == 1);

    But it seems sometimes its  not works.

    For now I am tranmitting 8 characters from device 1 to device 2.

    Device 2 trasnmit 16 characters to Device 1.

    Again Device 1 transmit 8 characters to Device 2.

    As you can see in attached images that I have set trasnmit fifo set level to 8 and set the transmit interrupt , attahed image for reference, In Interrupt i am not doing any task execution.

    So my question is , is there no API which tell us about transmit status?

    We have to tranmit the data from interrupt only, again when next tx interrupt will hit we should consider that privious data has been tranmitted , am I right?

    Thank you

    Shashank

     

  • Hi Shashank,

    Since the SCI_isTransmitterBusy() only checks if the FIFO is empty, it could return false even if there is still data present in the TX buffer or shift register. The TXEMPTY bit in the SCICTL2 register on the other hand only checks if the TX buffer and shift register are empty and does not check the TX FIFO. Since transmitted data goes to TX buffer -> TX FIFO -> TX shift register, you want to know when all three of these are empty (if I am understanding your application correctly). Also, you would want the while loop to loop while(SciaRegs.SCICTL2.bit.TXEMPTY == 0) "while it is not empty" so that it will break out when it is actually empty.

    The API functions were made to detect when data can be written to the SCI transmitter without data loss rather than detecting when the transmission on the TX line is actually finished, so we do not have an API function for your exact case. Can you try the following in your code:

    while( (SciaRegs.SCICTL2.bit.TXEMPTY == 0) && (SCI_isTransmitterBusy()) );

    You can then toggle your GPIO after this while loop is broken out off, which would indicate that the transmitter is done transmitting all data. In this case you should have no need to enable the SCI TX interrupts. The TXRDY flag triggers the SCI TX interrupt and this doesn't trigger on the exact condition you are looking for either. Let me know if this fixes your issue.

    Best Regards,

    Delaney