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.

TMS320F28335: How to send char consecutively through SCI using FIFO and Interrupt?

Part Number: TMS320F28335

Dear Expert,

I am attempting to send a sequence of characters consecutively using FIFO and Interrupts. For example, in the code, I am using "S+0123456789ABCD," which consists of 16 characters. I need these characters to appear on the RX in the order from "S" to "D."

 

I have modified the program based on the example "Example_2833xSci_FFDLB_int." I am using SCI-B with a baud rate of 9600 (LSPCLK = 75 MHz), and the code is running in loopback mode.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
// Prototype statements for functions found within this file.
interrupt void scibTxFifoIsr(void);
interrupt void scibRxFifoIsr(void);
void scib_fifo_init_user(void);
// Global variables
Uint16 sdataB[16]; // Send data for SCI-B
Uint16 rdataB[16]; // Received data for SCI-B
int send_b_count = 0;
int receive_b_count = 0;
char receive_b_char[17];
Uint16 count_b_S = 0;
Uint16 count_b_plus = 0;
Uint16 count_b_0 = 0;
Uint16 count_b_1 = 0;
Uint16 count_b_2 = 0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The problem is that I did not get the characters to appear in the right order. Also, when I calculate the appearance of every character in the RX interrupt, I get different values counted. The "S" character seems to appear very frequently compared to others, as shown in the figure.

 

I also tried with another size of FIFO depth, for example by using FIFO depth of 9. And change every following line of code (change from 16 to 9):

Fullscreen
1
2
3
4
5
6
ScibRegs.SCIFFTX.all = 0xC029;
ScibRegs.SCIFFRX.all = 0x0029;
for (kbrx = 0; kbrx < 9 ; kbrx++) {}
for (kb = 0; kb < 9; kb++) {}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

But there is a problem where the first two characters (the "S" and "+") do not appear on the RX side (see the figure).

 

So, my questions are:

  1. How can I send the characters in the correct order? Also, how can I avoid multiple same characters showing up in the RX FIFO when receiving from the TX FIFO?
  2. How can I determine the correct size of the FIFO depth? I perceive that the example is using an 8-size depth FIFO, as the data is sent 8 times to SCITXBUF. But why do I lose the first two bytes when I set the FIFO size to 9 in my code, although I have already set it to send 9 times to SCITXBUF just like the example does?

 

I sincerely hope to hear from you soon.

 

Warm regards,

Alif

  • Hi Alif,

    Thanks for your questions.

    This actually looks like you are overrunning the buffer. Can you check the error registers and see if you have a TX overflow? I think what's happening is that you are REPEATEDLY sending data to the TX without waiting for "TXRDY" to be asserted again. Basically, the TX buffer/FIFO is overflowing because you are writing to it faster than the data can send.

    Regards,

    Vince

  • Dear Vince,

    Thank you for your response, by changing the code in TX interrupt, I can make it work for now

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    while (ScibRegs.SCIFFTX.bit.TXFFST != 0) {}
    if (ScibRegs.SCICTL2.bit.TXRDY != 0) {
    Uint16 kb;
    for(kb = 0; kb < 16; kb++) {
    ScibRegs.SCITXBUF = sdataB[kb]; // Send data
    }
    ScibRegs.SCIFFTX.bit.TXFFINTCLR = 1; // Clear Interrupt flag
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Apparently, it can also use this 

    if (ScibRegs.SCIFFTX.bit.TXFFST == 0) { ... }


    I will make this as resolved and make new question that I want to ask.

    Thank you