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.

TMS570LS3137: TMS570 SCI transmit problem (TX RDY flag)

Part Number: TMS570LS3137

I am using the LIN/SCI device in SCI / UART mode.

Wrting a seqeunce of 3 bytes to the TD register, only the last one is transmitted over the line (scope).

It seems as if the TX RDY flag in the SCIFLR register is never CLEARED.

As i am polling the TX RDY flag before writing the next byte to the TD, obviously the last of the sequence of 3 bytes overwrites the precedent ones in the TD register and only the last one gets transmitted.

I checked the assembly code to verify that the FLR (FFF7E41C) is read out and compared (0x100 - bit 8 - TX RDY) in fact.

See the code below: The body of the while loop (waiting as long as TX RDY == 0) is never entered - verified in the debugger and by counter variables.

Only busy waiting via a counter (u16waitCnt) leads to the correct behaviour, i.e. all 3 characters on the line.

Btw. the solution shall work without interrupts.

Thank you,

Michael

____________________________________________________________________________________________________

void XX_InitPriv(void)
{



    sciREG1->GCR0 = 1U; // Bring the Module Out of Reset

    // stop the device for configuration
    sciREG1->GCR1 &= ~(1 << 7);


    // disable all interupts!!!!
    sciREG1->CLRINT    = 0xFFFFFFFF;
    sciREG1->CLRINTLVL = 0xFFFFFFFF;


    // setup the UART for the LCD -> 1 start, 1 stop, no parity
    sciREG1->GCR1 = 0x0200002A; // Enable ONLY Transmit functionality!

    sciREG1->BAUD = 600; // baud rate --- 9600 from 80MHz VCLK

    sciREG1->LENGTH = 7; // 8 bit Data length

    sciREG1->FUN = 0x00000006; // Enabling Tx and Rx pins

    sciREG1->PSL = 0x00000006; //Enable PULL Up functionality for RX and TX Pins



    // clear flags
    sciREG1->FLR = 0xFFFFFFFF;

    // set bit 4, start the device
    sciREG1->GCR1 |= 0x00000080; //End of Module Configuration

}


void XX_LCD(void)
{
    static uint8 u8blink = 0;
    uint8 i;
    uint16 u16waitCnt;
    // set cursor pos 4, set a .
    uint8 u8data[3] = {0xFE, 0x83, '.'};


    // switch the blinking . every other second
    if (u8blink == 0)
    {
        u8blink = 1;
        u8data[2] = ' ';
    }
    else
    {
        u8blink = 0;
    }



    // write the 3 char buffer

    // TX 1st byte
    sciREG1->TD = u8data[0];

    for (i=1; i< 3; i++)
    {

        u16waitCnt = 0;
        // wait for the SCI tx to become ready - SCIFLR / bit 8 TXRDY
        while  ( ((sciREG1->FLR & SCI_TX_INT) == 0) ||
               (u16waitCnt < 0x1500) )    // <---- Original code without this busy wait condition (counter)!!
        {
            u16waitCnt++;
        }

        sciREG1->TD = u8data[i];

    }

}

  • Remark: The device is operated with memory protection enabled. The SCI initialization function is executed in privileged mode. The tasks accessing the TD and the FLR register (LCD function) has MPU R/W permission the the resp. I/O memory region (0xFFF7E400 ..)
    But as characters are transmitted on the line I do not assume anything else could possibly be wrong regarding operating the SCI with MPU enabled.
  • Hi Michael,

    I don't see the problem in your code. If the timeout counter (u16waitCnt < 0x1500 ) is not in your while loop, the 3rd data won't be transmitted. Writing u8data[0] to SCITD register clears the TXRDY, and TXRDY is set only after the data in TD is shifted into the shift register (SCITXSHF).
  • Hi QJ,

    thank you very much for your fast reply.

    Regardless whether I change the code like below , that is sending the 1st byte after the while statement with the TX RDY test condition:

    the result is always the same - only the very LAST byte of the array is transmitted on the line (scope). Regadless if it is only 3 bytes or more.

    The counter u16waitCnt will always be 0, regardless how many bytes are sent.

    Michael

    void XX_Write_LCD(uint8* pU8data, uint8 u8len)
    {
    
        uint8 i;
        uint16 u16waitCnt;
    
    
        u16waitCnt = 0;
    
        for (i=0; i< u8len; i++)
        {
    
            // wait for the SCI tx to become ready - SCIFLR / bit 8 TXRDY
            while   ((sciREG1->FLR & SCI_TX_INT) == 0)
            {
                u16waitCnt++;
            }
    
            sciREG1->TD = pU8data[i];
    
        }
    
    }

  • Hi Michael,

    Have you solved the problem?
  • Hi QJ,

    Thank you for asking. No, not yet.

    There is probably still some error, even if my code looks correctly compared to other examples here in the Forum and in TI app notes.

    Perhaps the initialization of other devices influences the behaviour of the SCI - however i cannot imaginge that this could happen for the flags in the SCIFLR..

    I will post any findings here.

    However, it is no urgent matter as i intended to use the LIN/UART port for developing purposes only.

    Regards,

    Michael

  • Btw, shall i close the issue?

    Michael
  • Hello Michael,

    I comment out one statement of your code, it works. In your code, you clear all the pin in flag register including TX_EMPTY, TX_RDY, and IDLE bits.

    Here is the working code:

    int main(void)

    {

    /* USER CODE BEGIN (3) */

       //sciInit();

       uint8 i, u8len=19;

       uint16 u16waitCnt;

       u16waitCnt = 0;

       uint8 u8data[19]= {'T','E','X','A','S',' ','I','N','S','T','R','U','M','E','N','T','S','\n','\r'};

    //    sciInit();

       scilinREG->GCR0 = 1U; // Bring the Module Out of Reset

       // stop the device for configuration

       scilinREG->GCR1 &= ~(1 << 7);

       // disable all interupts!!!!

       scilinREG->CLEARINT    = 0xFFFFFFFF;

       scilinREG->CLEARINTLVL = 0xFFFFFFFF;

       // setup the UART for the LCD -> 1 start, 1 stop, no parity

       scilinREG->GCR1 = 0x0200002A; // Enable ONLY Transmit functionality!

       scilinREG->BRS = 520; // baud rate --- 9600

       scilinREG->FORMAT = 7; // 8 bit Data length

       scilinREG->PIO0 = 0x00000006; // Enabling Tx and Rx pins

       scilinREG->PIO7 = 0x00000006; //Enable PULL Up functionality for RX and TX Pins

       // clear flags

    //    scilinREG->FLR = 0xFFFFFFFF;

       // set bit 4, start the device

       scilinREG->GCR1 |= 0x80; //End of Module Configuration

       // TX 1st byte

       for (i=0; i< u8len; i++)

       {

           // wait for the SCI tx to become ready - SCIFLR / bit 8 TXRDY

           while   ((scilinREG->FLR & SCI_TX_INT) == 0)

           {

               u16waitCnt++;

           }

           scilinREG->TD = (uint32)u8data[i];

       }

       while(1);

    }