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.

TMS320F28069M UART, internal loop back work, external loop back fails, RXRDY never fires



For some reason, I can not get the UART receive RXRDY to fire with an external loop back.  I am monitoring signals on an oscilloscope and i can see the levels shifting correctly, correct width based on baud, etc... so i know the data is right.

Also, with internal loopback set, RXRDY fires as expected and i can read the rxbuf, however with an external loopback it never fires. 

I have also tried using the FIFO functionality and get the exact same results, RXFFST only fires when i have Internal loopback enabled, not when i use an external loopback. 

Code below...

void TMS_OCP_Init()
{
    EALLOW; //Needed to write to protected registers

    // Setup TMS_OCP_ENABLE line on GPIO21
    GpioCtrlRegs.GPAPUD.bit.GPIO21 = 0;   // Enable pullup
    GpioDataRegs.GPASET.bit.GPIO21 = 1;   // Load output latch
    //GpioDataRegs.GPACLEAR.bit.GPIO21 = 1; // Clear output latch
    GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 0;  // GPIO21 = GPIO21
    GpioCtrlRegs.GPADIR.bit.GPIO21 = 1;   // GPIO21 = output
    // Setup TMS_OCP_FAULT input line on GPIO21
    GpioCtrlRegs.GPBPUD.bit.GPIO43 = 1;   // Disable pullup
    //GpioDataRegs.GPBSET.bit.GPIO43 = 1;   // Load output latch
    GpioCtrlRegs.GPBMUX1.bit.GPIO43 = 0;  // GPIO43 = GPIO43
    GpioCtrlRegs.GPBDIR.bit.GPIO43 = 0;   // GPIO43 = input
    // Setup SCIRXDB and SCITXDB
    GpioCtrlRegs.GPAPUD.bit.GPIO11 = 0;    // Enable pull-up for GPIO11 (SCIRXDB)
    GpioCtrlRegs.GPBPUD.bit.GPIO58 = 0;       // Enable pull-up for GPIO58 (SCITXDB)
    /* Set qualification for selected pins to asynch only */
    // Inputs are synchronized to SYSCLKOUT by default.
    // This will select asynch (no qualification) for the selected pins.
    GpioCtrlRegs.GPAQSEL1.bit.GPIO11 = 3;  // Asynch input GPIO11 (SCIRXDB)
    /* Configure SCI-B pins using GPIO regs*/
    // This specifies which of the possible GPIO pins will be SCI functional pins.
    GpioCtrlRegs.GPBMUX2.bit.GPIO58 = 2;   // Configure GPIO58 for SCITXDB operation
    GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 2;   // Configure GPIO11 for SCIRXDB operation

    //GpioCtrlRegs.GPAPUD.bit.GPIO19 = 0;    // Enable pull-up for GPIO11 (SCIRXDB)
    //GpioCtrlRegs.GPAQSEL2.bit.GPIO19 = 3;  // Asynch input GPIO11 (SCIRXDB)
    //GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 2;   // Configure GPIO11 for SCIRXDB operation
    //GpioCtrlRegs.GPAPUD.bit.GPIO11 = 1;    // Enable pull-up for GPIO11 (SCIRXDB)
    //GpioCtrlRegs.GPAPUD.bit.GPIO19 = 1;   // Disable pullup
    //GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 0;  // GPIO19 = GPIO19
    //    GpioCtrlRegs.GPADIR.bit.GPIO19 = 0;   // GPIO19 = input

    EDIS;

    scib_init();
    //scib_fifo_init();
    SerialInit();
}
// SCIA  8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
void scib_init()
{
    // Note: Clocks were turned on to the SCIB peripheral
    // in the InitSysCtrl() function
    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.SCIBENCLK = 1;     // SCI-B enable periphreal clock
    EDIS;

    ScibRegs.SCICTL1.all =0x0003;  // enable TX, RX, internal SCICLK,  //MAKE SURE TO SET SW_RESETn = 0
                                   // Disable RX ERR, SLEEP, TXWAKE

     //ScibRegs.SCICCR.all =0x0007;   // 1 stop bit,  No loopback
                                   // No parity,8 char bits,
                                   // async mode, idle-line protocol

     ScibRegs.SCICCR.all =0x0017;   // 1 stop bit,  LOOPBACK FOR TESTING
                                   // No parity,8 char bits,
                                   // async mode, idle-line protocol

    ScibRegs.SCICTL2.bit.TXINTENA =1;  // can probably remove these, not using interrupts for sci w/ 15khz motor control loop
    ScibRegs.SCICTL2.bit.RXBKINTENA =1;// can probably remove these, not using interrupts for sci w/ 15khz motor control loop

    ScibRegs.SCIHBAUD    =0x0000;
//    ScibRegs.SCILBAUD    =0x0017;  // 115200 baud @LSPCLK = 22.5MHz (90 MHz SYSCLK).
    ScibRegs.SCILBAUD    =0x0059;    // 115200 baud @LSPCLK = 90MHz (90 MHz SYSCLK).
                                     // 0x0060 or 0x0061 would probably be closer to 115200, used 0x005F to scale by 4 from previous example

    ScibRegs.SCICTL1.all =0x0023;  // Relinquish SCI from Reset
}
void scib_fifo_init()
{
    ScibRegs.SCIFFTX.all = 0xE040;
    ScibRegs.SCIFFRX.all = 0x2044;
    ScibRegs.SCIFFCT.all = 0;
}


int UART_polled_rx(uint8 * pData)
{
    //TMS320 Rx Read
    f = ScibRegs.SCIRXST.all;
    //if(ScibRegs.SCIFFRX.bit.RXFFST)
    if(ScibRegs.SCIRXST.bit.RXRDY)
    {
        *pData = (uint8)ScibRegs.SCIRXBUF.all;
        h = *pData; //watch window
        return 1;
    }
    return 0;
}

void UART_polled_tx(uint8 * pData)
{
    while(ScibRegs.SCICTL2.bit.TXRDY == 0){} //Make sure TxBuf is empty
    ScibRegs.SCITXBUF = *pData;
    g = *pData; //watch window
}




TMS_OCP_Init();

void mainISR(void) //15khz
{
    char a = 0;
    char b = 0xA5;

    UART_polled_rx(&a);
    UART_pollex_tx(&b);
}