Tool/software: Code Composer Studio
Hi
Using the example I wrote programm for SCI-C and I have a problem.I use external rs232 to transfer data. When I set baud for 115200 or 57600 I receives 0. When I used lower baud (for example 9600) I receives correct values. Would you have any idea what is wrong with my code ?
Thank you for help
Best regards
Szymon
#include "F28x_Project.h"
Uint16 LoopCount;
Uint16 ErrorCount;
void scia_loopback_init(void);
void scia_fifo_init(void);
void scia_xmit(int a);
void error();
void main(void)
{
Uint16 SendChar;
Uint16 ReceivedChar;
InitSysCtrl();
InitGpio();
EALLOW;
GpioCtrlRegs.GPCMUX2.bit.GPIO89 = 2; // tx
GpioCtrlRegs.GPCMUX2.bit.GPIO90 = 2; // rx
GpioCtrlRegs.GPCGMUX2.bit.GPIO89 = 1; // tx
GpioCtrlRegs.GPCGMUX2.bit.GPIO90 = 1; // rx
DINT;
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EnableInterrupts();
LoopCount = 0;
ErrorCount = 0;
scia_fifo_init(); // Initialize the SCI FIFO
scia_loopback_init(); // Initialize SCI for digital loop back
SendChar = 0xAF;
//
for(;;)
{
scia_xmit(SendChar);
//
// wait for RRDY/RXFFST =1 for 1 data available in FIFO
//
while(ScicRegs.SCIFFRX.bit.RXFFST == 0) { }
//
// Check received character
//
ReceivedChar = ScicRegs.SCIRXBUF.all;
if(ReceivedChar != SendChar)
{
error();
}
LoopCount++;
}
}
//
// error - Function to count errors
//
void error()
{
ErrorCount++;
// asm(" ESTOP0"); // Uncomment to stop the test here
// for (;;);
}
//
// scia_loopback_init - Configure SCIA settings
//
void scia_loopback_init()
{
//
// Note: Clocks were turned on to the SCIA peripheral
// in the InitSysCtrl() function
//
ScicRegs.SCICCR.all = 0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
ScicRegs.SCICTL1.all = 0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
ScicRegs.SCICTL2.all = 0x0003;
ScicRegs.SCICTL2.bit.TXINTENA = 1;
ScicRegs.SCICTL2.bit.RXBKINTENA = 1;
ScicRegs.SCIHBAUD.all = 0x03; //for 115200 9600 - 0x02
ScicRegs.SCILBAUD.all = 0x06; //for 115200 9600 - 0x8B
ScicRegs.SCICCR.bit.LOOPBKENA = 1; // Enable loop back
ScicRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
}
//
// scia_xmit - Transmit a character from the SCI
//
void scia_xmit(int a)
{
ScicRegs.SCITXBUF.all=a;
}
//
// scia_fifo_init - Initialize the SCI FIFO
//
void scia_fifo_init()
{
ScicRegs.SCIFFTX.all = 0xE040;
ScicRegs.SCIFFRX.all = 0x2044;
ScicRegs.SCIFFCT.all = 0x0;
}
