TMS320F280038C-Q1: DMA enabled UART for debugging purposes

Part Number: TMS320F280038C-Q1
Other Parts Discussed in Thread: C2000WARE

Hi Champs,

Customer works on an OBC , USB debugger sometimes crashes because of noises.
Therefore they are using modbus protocol over UART/RS485 (SCI) for real time debugging. This is very useful for them.

Since we do not have DMA enablement for F280038 for SCI, they have to use main loop to send very long strings to PC over Uart/Rs485.
Even if 250k baud is used, they do waste a lot of time in the main loop with long string values.

They would appreciate any suggestion how they can use DMA for this purpose. 

CLA is not utilized. Can they eventually mimic high speed, DMA enabled UART using CLA?

Any hints/best practices woudl be highly appreciated.

With best regards

Tamas

  • Hi Tamas,

    You are correct in that the SCI module on the F28003x does not have DMA access. I would recommend one of the following approaches:

    1. Use an interrupt-based approach with SCI to avoid spending CPU time in the main loop while waiting for space in the TX buffer. We have a software example illustrating this functionality in the C2000ware package. It can be found in [C2000ware install]/driverlib/f28003x/examples/sci/sci_ex2_loopback_interrupts.

    2. They could use the LIN module on the F28003x in SCI mode, which has DMA access and uses the standard UART protocol. An example of this is [C2000ware install]/driverlib/f28003x/examples/lin/lin_ex3_sci_dma.

    3. Another option would be to switch to the F28P65x or F2838x devices which have a UART module. The UART module has DMA access on both of these devices and offers higher speed and more fine-tuned baud rates as compared to the SCI module. Examples for this functionality can also be found in the C2000ware package in the uart folders of the relevant devices. 

    I would recommend they start with the first option and see if the performance improvement is acceptable. Let me know if they have any other questions. I can offer support for any of these options. 

    Best Regards,

    Delaney

  • Hi Delaney,

    Thank you for the suggestions.

    1. I think the time spending in main loops comes from the fact of having to feed UART buffer utilizing CPU due to lack of DMA. Doing the same from interrupt would not buy them extra processing time.

    2. LIN - can we do 250kbps with LIN? I thought it can go up to 19.2kbps only. Are you sure that they can use RS485 xciever for LIN?

    3. Do we have p2p compatible options across F2838x and F28P65x? - if so than this might be the best option.

    Talking to colleagues we also came up with a suggestion which I think is worth to mention - although customer has not commented it yet:

    "We have published years ago an application note about emulating UART TX with an SPI.

    This was for an Hercules MCU, but in principle I think that it could be applied to any SPI.
    Please see the application note here: https://www.ti.com/lit/spna234

    What about using DMA enabled SPI mimicked TX and the standard UART RX w interrupt – as is today.

    I think this could offload your main loop and at the same time maintain the UART RX functionality."

    Thanks and regards

    Tamas

  • Hi Tamas,

    Below are my responses.

    1. Are they polling the TXRDY flag (FIFO disabled) or the TXFFIL flag (FIFO enabled) in the main loop before writing data to the TX buffer? If so, using an interrupt would improve performance by avoiding having the CPU wait until there is space before writing. If not, they are likely going to experience data loss since they could be writing the TX buffer when it is full. Keep in mind that the SCI_writeCharArray() driverlib function and others do this polling before writing, so if they are calling this in their main loop, transmits will take a while. If they call it in a TX ISR however, the SCI_writeCharArray() will immediately break out of the polling loop since the condition will already be met.

    2. The maximum baud rate of the LIN module in LIN mode is 20kbps. However, if the LIN module is configured in SCI mode, the maximum baud rate is around 3.125 Mbps (assuming a CLK of 100MHz). And yes, this should work with the RS-485 as the physical protocol seen on the TX and RX pins of the device would be the same as with SCI.

    3. I don't believe we have pin-to-pin compatibility between F28003x and either of those devices unfortunately. You could check this in the "Pin Diagrams" section of the device datasheets to be sure though.

    4. The DMA does have access to SPI but I'm not sure how the SPI module would effectively imitate a UART protocol. Could you send me the source code for this, and I can see if it would be possible for C2000?

    Best Regards,

    Delaney

  • Hi Delaney,

    1. Customer decided to go on with their current implementation (option1 incl. interrupts). Due to their very aggressive timeline, they will not check the other options in this project.

    4. Please see attached the reference code for SPI based UART TX. There is no need for the moment to port it to C2000 or do any further actions about it. I'm just attaching for reference.

    Delaney, thank you for all your help!

    Tamas

    spnc049.zip

  • Hi Tamas,

    Sounds good, let me know if they have any other questions. 

    Thank you for sending the zip, I'm interested to see if this approach could work for C2000 as well.

    Best Regards,

    Delaney