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/TMS320F28377S: C2000

Part Number: TMS320F28377S


Tool/software: Code Composer Studio

Hi all,

I am using TMS320F28377S C2000 controller for my application.

I want to communicate controller with external devices via UART communication, for this purpose initially i want to get familiar UART communication of this controller.

I tried example code of control suite, In my point of view its not working. I am pasted my code below.

In this loop back mode working fine, but No data come out in SCIA-TX and RX pins(42,43). I am working in Lanuchpad

Regards,

Yuvaraj


//
// Included Files
//
#include "F28x_Project.h"

//
// Defines
//
#define CPU_FREQ 60E6
#define LSPCLK_FREQ CPU_FREQ/4
#define SCI_FREQ 100E3
#define SCI_PRD (LSPCLK_FREQ/(SCI_FREQ*8))-1

//
// Globals
//
Uint16 sdataA[2]; // Send data for SCI-A
Uint16 rdataA[2]; // Received data for SCI-A
Uint16 rdata_pointA; // Used for checking the received data

Uint16 a,j;
//
// Function Prototypes
//
interrupt void sciaTxFifoIsr(void);
interrupt void sciaRxFifoIsr(void);
void scia_fifo_init(void);
void error(void);

//
// Main
//
void main(void)
{
Uint16 i;

InitSysCtrl();
InitGpio();

GPIO_SetupPinMux(13, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(13, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(12, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(12, GPIO_OUTPUT, GPIO_PUSHPULL);

GPIO_SetupPinMux(42, GPIO_MUX_CPU1, 1);
GPIO_SetupPinOptions(42, GPIO_INPUT, GPIO_ASYNC);
GPIO_SetupPinMux(43, GPIO_MUX_CPU1, 1);
GPIO_SetupPinOptions(43, GPIO_OUTPUT, GPIO_ASYNC);

DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();

EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.SCIA_RX_INT = &sciaRxFifoIsr;
PieVectTable.SCIA_TX_INT = &sciaTxFifoIsr;
EDIS; // This is needed to disable write to EALLOW protected registers
scia_fifo_init(); // Init SCI-A

for(i = 0; i<2; i++)
{
sdataA[i] = i;
}

rdata_pointA = sdataA[0];

PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
PieCtrlRegs.PIEIER9.bit.INTx1 = 1; // PIE Group 9, INT1
PieCtrlRegs.PIEIER9.bit.INTx2 = 1; // PIE Group 9, INT2
IER = 0x100; // Enable CPU INT
EINT;

for(;;)
{
// Turn on LED
GPIO_WritePin(13, 0);
GPIO_WritePin(12, 1);


for(j = 0; j < 10000; j++)
{
for(a = 0; a < 100; a++)
{

}
}

// Turn off LED
GPIO_WritePin(13, 1);
GPIO_WritePin(12, 0);
for(j = 0; j < 10000; j++)
{
for(a = 0; a < 100; a++)
{

}
}

// Delay for a bit.
}
}

// error - Function to halt debugger on error
void error(void)
{
asm(" ESTOP0"); // Test failed!! Stop!
for (;;);
}

// sciaTxFifoIsr - SCIA Transmit FIFO ISR
interrupt void sciaTxFifoIsr(void)
{
Uint16 i;

for(i=0; i< 2; i++)
{
SciaRegs.SCITXBUF.all=sdataA[i]; // Send data
}

for(i=0; i< 2; i++) // Increment send data for next cycle
{
sdataA[i] = (sdataA[i]+1) & 0x00FF;
}

SciaRegs.SCIFFTX.bit.TXFFINTCLR=1; // Clear SCI Interrupt flag
PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ACK
}

// sciaRxFifoIsr - SCIA Receive FIFO ISR
interrupt void sciaRxFifoIsr(void)
{
Uint16 i;

for(i=0;i<2;i++)
{
rdataA[i]=SciaRegs.SCIRXBUF.all; // Read data
}

for(i=0;i<2;i++) // Check received data
{
if(rdataA[i] != ( (rdata_pointA+i) & 0x00FF) )
{
// error();
}
}

rdata_pointA = (rdata_pointA+1) & 0x00FF;

SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1; // Clear Overflow flag
SciaRegs.SCIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag

PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ack
}

// scia_fifo_init - Configure SCIA FIFO
void scia_fifo_init()
{
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.bit.TXINTENA = 1;
SciaRegs.SCICTL2.bit.RXBKINTENA = 1;
SciaRegs.SCIHBAUD.all = 0x0000;
SciaRegs.SCILBAUD.all = SCI_PRD;
SciaRegs.SCICCR.bit.LOOPBKENA = 0; // Enable loop back
SciaRegs.SCIFFTX.all = 0xC022;
SciaRegs.SCIFFRX.all = 0x0022;
SciaRegs.SCIFFCT.all = 0x00;

SciaRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
SciaRegs.SCIFFTX.bit.TXFIFORESET = 1;
SciaRegs.SCIFFRX.bit.RXFIFORESET = 1;
}

  • Hi Yuvaraj,

    From the code you are trying to configure the gpio 42 and 43 as SCiTXDA and SCIRXDA .
    But the gpio muxing configurations are incorrect .
    The 3rd parameter of the GPIO_SetupPinMux() APi is for mux options.

    if you see the datasheet of the device the mux positions are 15 and not 1 for the SCIA tx and rx .
    www.ti.com/.../sprs881d.pdf


    Change :
    GPIO_SetupPinMux(42, GPIO_MUX_CPU1, 1); &
    GPIO_SetupPinMux(43, GPIO_MUX_CPU1, 1);

    To

    GPIO_SetupPinMux(42, GPIO_MUX_CPU1, 0xF); &
    GPIO_SetupPinMux(43, GPIO_MUX_CPU1, 0xF);

    You should be able to see the data come out on the line .

    Regards.
  • Yuva,

    Please see Meghana's response.

    What platform of the F2837x are you using? Are you using a controlCARD or a Launchpad?

    If you are using an on board FTDI chip for the UART/SCI serial communication, then please make sure you are using and configuring the correct GPIO pins for SCI communication which are routed to the FTDI chip.

    Regards,
    sal
  • I am using Launch pad(Already mentioned)