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.

CCS/TMS320F28035: SCI communication two F28035

Part Number: TMS320F28035
Other Parts Discussed in Thread: TMDSCNCD28035, TMDSCNCD28035ISO, C2000WARE

Tool/software: Code Composer Studio

Hi,

I am trying to communicate between two F28035 via SCI. One F28035 receiver, one F28035 transmitter. I connected transmitter F28035's tx to receiver F28035's rx. But I could not see any value on the rx buffer. How can I fix this? Meanwhile I programmed two MCU on the same PC. I used LED3 for understanding which device working now.

Transmitter Code

#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

// Prototype statements for functions found within this file.
void scia_loopback_init(void);
void scia_fifo_init(void);
void scia_xmit(int a);
void error();
__interrupt void scia_rx_isr(void);
__interrupt void scia_tx_isr(void);

// Global counts used in this example
Uint16 LoopCount;
Uint16 ErrorCount;

void main(void)
{
    static volatile Uint16 GPIO34_count = 0;
    Uint16 SendChar;
    Uint16 ReceivedChar;

    // Step 1. Initialize System Control registers, PLL, WatchDog, Clocks to default state:
    // This function is found in the DSP2803x_SysCtrl.c file.
    InitSysCtrl();

    // Step 2. Select GPIO for the device or for the specific application:
    // This function is found in the DSP2803x_Gpio.c file.
    // InitGpio(); skip this as this is example selects the I/O
    // for SCI-A in this file itself
    InitSciGpio();

    // Step 3. Initialize PIE vector table:
    // The PIE vector table is initialized with pointers to shell Interrupt
    // Service Routines (ISR).  The shell routines are found in DSP2803x_DefaultIsr.c.
    // Insert user specific ISR code in the appropriate shell ISR routine in
    // the DSP28_DefaultIsr.c file.

    // Disable and clear all CPU interrupts:
    DINT;
    IER = 0x0000;
    IFR = 0x0000;

    // Initialize Pie Control Registers To Default State:
    // This function is found in the DSP2803x_PieCtrl.c file.
    // InitPieCtrl();  PIE is not used for this example

    // Initialize the PIE Vector Table To a Known State:
    // This function is found in DSP2803x_PieVect.c.
    // This function populates the PIE vector table with pointers
    // to the shell ISR functions found in DSP2803x_DefaultIsr.c.
    InitPieVectTable();

    // Enable CPU and PIE interrupts
    // This example function is found in the DSP2803x_PieCtrl.c file.
    EnableInterrupts();

    // Step 4. Initialize all the Device Peripherals to a known state:
    // Skip this for SCI tests

    // Step 5. User specific functions, Reassign vectors (optional), Enable Interrupts:
    LoopCount = 0;
    ErrorCount = 0;

    scia_fifo_init();      // Initialize the SCI FIFO
    scia_loopback_init();  // Initialize SCI for digital loop back

    // Note: Autobaud lock is not required for this example

    // Send a character starting with 0
    SendChar = 0;

    // Step 6. Send Characters forever starting with 0x00 and going through
    // 0xFF.  After sending each, check the receive buffer for the correct value
    for(;;)
    {
        scia_xmit(SendChar);
        //while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for RRDY/RXFFST =1 for 1 data available in FIFO

        // Check received character
        //ReceivedChar = SciaRegs.SCIRXBUF.bit.RXDT;
        //if(ReceivedChar != SendChar) error();

        // Move to the next character and repeat the test
        SendChar++;
        // Limit the character to 8-bits
        SendChar &= 0x00FF;
        LoopCount++;

        if(GPIO34_count++ > 60000)                  // Toggle slowly to see the LED blink
        {
            GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1;  // Toggle the pin
            GPIO34_count = 0;                       // Reset the counter
        }
    }
}


// Step 7. Insert all local Interrupt Service Routines (ISRs) and functions here:
void error()
{
    ErrorCount++;
    //    __asm("     ESTOP0");  // Uncomment to stop the test here
    //    for (;;);
}

// Test 1, SCIA  DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
void scia_loopback_init()
{
    // Note: Clocks were turned on to the SCIA peripheral
    // in the InitSysCtrl() function

    SciaRegs.SCICCR.all =0x0007;   // 1 stop bit,  No loopback
    // No parity,8 char bits,
    // async mode, idle-line protocol
    SciaRegs.SCICTL1.all =0x0003;  // enable TX, RX, internal SCICLK,
    // Disable RX ERR, SLEEP, TXWAKE
    SciaRegs.SCICTL2.all =0x0003;
    SciaRegs.SCICTL2.bit.TXINTENA =1;
    SciaRegs.SCICTL2.bit.RXBKINTENA =1;
    SciaRegs.SCIHBAUD    =0x0000;
    SciaRegs.SCILBAUD    =0x00C2;     // BaudRate 9600
    SciaRegs.SCICCR.bit.LOOPBKENA = 0; // Enable loop back
    SciaRegs.SCICTL1.all =0x0023;     // Relinquish SCI from Reset
}

// Transmit a character from the SCI
void scia_xmit(int a)
{
    SciaRegs.SCITXBUF=a;
}

// Initialize the SCI FIFO
void scia_fifo_init()
{
    SciaRegs.SCIFFTX.all=0xE040;
    SciaRegs.SCIFFRX.all=0x2044;
    SciaRegs.SCIFFCT.all=0x0;
}
//===========================================================================
// No more.
//===========================================================================


Receiver Code

#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

// Prototype statements for functions found within this file.
void scia_loopback_init(void);
void scia_fifo_init(void);
void scia_xmit(int a);
void error();
__interrupt void scia_rx_isr(void);
__interrupt void scia_tx_isr(void);

// Global counts used in this example
Uint16 LoopCount;
Uint16 ErrorCount;

void main(void)
{
    static volatile Uint16 GPIO34_count = 0;
    Uint16 SendChar;
    Uint16 ReceivedChar;

    // Step 1. Initialize System Control registers, PLL, WatchDog, Clocks to default state:
    // This function is found in the DSP2803x_SysCtrl.c file.
    InitSysCtrl();

    // Step 2. Select GPIO for the device or for the specific application:
    // This function is found in the DSP2803x_Gpio.c file.
    // InitGpio(); //skip this as this is example selects the I/O
    // for SCI-A in this file itself
    InitSciGpio();

    // Step 3. Initialize PIE vector table:
    // The PIE vector table is initialized with pointers to shell Interrupt
    // Service Routines (ISR).  The shell routines are found in DSP2803x_DefaultIsr.c.
    // Insert user specific ISR code in the appropriate shell ISR routine in
    // the DSP28_DefaultIsr.c file.

    // Disable and clear all CPU interrupts:
    DINT;
    IER = 0x0000;
    IFR = 0x0000;

    // Initialize Pie Control Registers To Default State:
    // This function is found in the DSP2803x_PieCtrl.c file.
    //InitPieCtrl();  //PIE is not used for this example

    // Initialize the PIE Vector Table To a Known State:
    // This function is found in DSP2803x_PieVect.c.
    // This function populates the PIE vector table with pointers
    // to the shell ISR functions found in DSP2803x_DefaultIsr.c.
    InitPieVectTable();

    // Enable CPU and PIE interrupts
    // This example function is found in the DSP2803x_PieCtrl.c file.
    EnableInterrupts();

    // Step 4. Initialize all the Device Peripherals to a known state:
    // Skip this for SCI tests

    // Step 5. User specific functions, Reassign vectors (optional), Enable Interrupts:
    LoopCount = 0;
    ErrorCount = 0;

    scia_fifo_init();      // Initialize the SCI FIFO
    scia_loopback_init();  // Initialize SCI for digital loop back

    // Note: Autobaud lock is not required for this example

    // Send a character starting with 0
    //SendChar = 111;

    // Step 6. Send Characters forever starting with 0x00 and going through
    // 0xFF.  After sending each, check the receive buffer for the correct value
    for(;;)
    {
        //scia_xmit(SendChar);

        //while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for RRDY/RXFFST =1 for 1 data available in FIFO

        // Check received character
        ReceivedChar = SciaRegs.SCIRXBUF.all;
        //if(ReceivedChar != SendChar) error();

        // Move to the next character and repeat the test
        //SendChar++;
        // Limit the character to 8-bits
        //SendChar &= 0x00FF;
        LoopCount++;

        if(GPIO34_count++ > 60000)                  // Toggle slowly to see the LED blink
        {
            GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1;  // Toggle the pin
            GPIO34_count = 0;                       // Reset the counter
        }
    }
}


// Step 7. Insert all local Interrupt Service Routines (ISRs) and functions here:
void error()
{
    ErrorCount++;
    //    __asm("     ESTOP0");  // Uncomment to stop the test here
    //    for (;;);
}

// Test 1, SCIA  DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
void scia_loopback_init()
{
    // Note: Clocks were turned on to the SCIA peripheral
    // in the InitSysCtrl() function

    SciaRegs.SCICCR.all =0x0007;   // 1 stop bit,  No loopback
    // No parity,8 char bits,
    // async mode, idle-line protocol
    SciaRegs.SCICTL1.all =0x0003;  // enable TX, RX, internal SCICLK,
    // Disable RX ERR, SLEEP, TXWAKE
    SciaRegs.SCICTL2.all =0x0003;
    SciaRegs.SCICTL2.bit.TXINTENA =1;
    SciaRegs.SCICTL2.bit.RXBKINTENA =1;
    SciaRegs.SCIHBAUD    =0x0000;
    SciaRegs.SCILBAUD    =0x00C2;
    SciaRegs.SCICCR.bit.LOOPBKENA = 0; // Enable loop back
    SciaRegs.SCICTL1.all =0x0023;     // Relinquish SCI from Reset
}

// Transmit a character from the SCI
void scia_xmit(int a)
{
    SciaRegs.SCITXBUF=a;
}

// Initialize the SCI FIFO
void scia_fifo_init()
{
    SciaRegs.SCIFFTX.all=0xE040;
    SciaRegs.SCIFFRX.all=0x2044;
    SciaRegs.SCIFFCT.all=0x0;
}
//===========================================================================
// No more.
//===========================================================================


  • User5803443,

    In the receiver code you have the following commented out:

    while(SciaRegs.SCIFFRX.bit.RXFFST !=1)
    {

    }

    Include the above for proper FIFO operation. Also, double check that you are using the correct GPIO for this example: GPIO28 is SCIRXDA and GPIO29 is SCITXDA.

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks.

    - Ken
  • Hi Ken,
    I commented out ;
    while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for RRDY/RXFFST =1 for 1 data available in FIFO
    But nothing changed. Also I checked the GPIO pins two MCU. Those are correct.

    I noticed two MCU working correctly with hardware loopback. I tried to connect Rx and Tx pin while code is running. I expected the transmission to begin. As a result nothing has changed.

    I programming two MCU at the same PC. Could the problem be caused by this?

    Also My GPIO configuration as follow,

    void InitSciaGpio()
    {
       EALLOW;
    
    /* Enable internal pull-up for the selected pins */
    // Pull-ups can be enabled or disabled disabled by the user.
    // This will enable the pullups for the specified pins.
    
    	GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0;    // Enable pull-up for GPIO28 (SCIRXDA)
    //	GpioCtrlRegs.GPAPUD.bit.GPIO7 = 0;     // Enable pull-up for GPIO7  (SCIRXDA)
    
    	GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0;	   // Enable pull-up for GPIO29 (SCITXDA)
    //	GpioCtrlRegs.GPAPUD.bit.GPIO12 = 0;	   // Enable pull-up for GPIO12 (SCITXDA)
    
    /* 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.GPAQSEL2.bit.GPIO28 = 3;  // Asynch input GPIO28 (SCIRXDA)
    //	GpioCtrlRegs.GPAQSEL1.bit.GPIO7 = 3;   // Asynch input GPIO7 (SCIRXDA)
    
    /* Configure SCI-A pins using GPIO regs*/
    // This specifies which of the possible GPIO pins will be SCI functional pins.
    
    	GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1;   // Configure GPIO28 for SCIRXDA operation
    //	GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 2;    // Configure GPIO7  for SCIRXDA operation
    
    	GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1;   // Configure GPIO29 for SCITXDA operation
    //	GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 2;   // Configure GPIO12 for SCITXDA operation
    
    	GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0;
    	GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;         // GPIO31 is an output (connected to LED2 on F28035 ControlCARD)
    	GpioDataRegs.GPBSET.bit.GPIO34 = 1;         // GPIO31 pin is set to 1 (turn LED on)
    
        EDIS;
    }



    Regards.

  • User5803443,

    Could you please let me know which device evaluation tool you are using? Is it the Experimenter kit? If so, is the controlCARD the TMDSCNCD28035 (standard controlCARD) or the TMDSCNCD28035ISO (Isolated controlCARD)? On the Docking Station, please let me know which header pins you are using and how you are connecting them.

    - Ken
  • Ken,
    I have one Isolated controlCARD and one standard controlCARD. I use GPIO28 for RX and GPIO29 for TX. I connected Isolated controlCARD 's Rx to controlCARD's Tx and vise versa. Also I connected two GND each other. While transmitter is working, I load code receiver. Receiver take value but I saw another two different value. I try to send 10. I took 10 but at the same time I see 33 and 72.This garbage values occured when I paused tranmitter.At the same time garbage values occured when I paused the receiver code. I can not understand this situation.
    Regards.

  • User5803443,

    Note that the standard controlCARD and the isolated controlCARD are different with respect to the standard controlCARD includes a transceiver while the isolated controlCARD does not. Please see the Info-Sheet for each in C2000Ware at:

    C:\ti\c2000\C2000Ware_<version>\boards\controlCARDs\TMDSCNCD28035\R1_2\F2803xcontrolCARD_InfoSheet.pdf

    C:\ti\c2000\C2000Ware_<version>\boards\controlCARDs\TMDSCNCD28035ISO\F28035_ISOcontrolCARD_InfoSheet.pdf

    In the standard controlCARD Info-Sheet see the SW1 settings on page 2.

    I suggest trying to get everything working using the FTDI UART channels (via USB cables). This will prove that the software is working as expected. Then after you have this working, you can experiment with a working system that does not use the FTDI channels, but you will probably still need to have the transceivers. (It might be better if you had two standard controlCARDs since both will have the transceivers).

    When using the FTDI channels you will need to the USB on the Docking Station for the standard controlCARD, while making sure that the proper switches are set correctly on the controlCARD and making sure the need jumpers are in placed on the Docking Station. For the Docking Station, see:

    C:\ti\c2000\C2000Ware_<version>\boards\ExperimenterKits\DockingStation_DIM_100pin\R3\USBDockingStation_Schematic_[R3].pdf

    Note the use of the Docking Station jumper J9. Please see:

    e2e.ti.com/.../665480

    For the isolated controlCARD you will need to use the USB on the controlCARD, while making sure that the proper switches are set correctly. It might be useful to have an oscilloscope available to make sure the signal is progressing through the signal chain.

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks.

    - Ken

  • Hi Ken,
    Thanks for response. I solved my problem. For two device I loaded both code receiver and transmitter each MCU. In this way I smooth away from garbage values. I think this garbage values source coming from ıdle other pin (Rx for transmitter, Tx for receiver).
    Regards.