Other Parts Discussed in Thread: MAX3232,
Tool/software: Code Composer Studio
I am using TMS320F28377S microcontroller. and I trying to use serial communication. I use the example code provided in control suit "sci_echoback". Microcontroller generate output on tx but I thing baud rate is not matching (i test this on putty) . I use this code.This give garbage value on putty. (Putty setting are correct I check then by shorting tx , rx pin of RS232, and max3232 is used for ttl to rs232 converter). Baud rate I set is 2400, Date Bits = 8,Parity = None, Stop Bits = 1, Hardware Control = None.I use c2000 launchpad XL, crystal freq=10Mhz,Clock is 200Mhz.
void main(void)
{
InitSysCtrl();
InitGpio();
GPIO_SetupPinMux(15, GPIO_MUX_CPU1, 2);
GPIO_SetupPinOptions(15, GPIO_INPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(14, GPIO_MUX_CPU1, 2);
GPIO_SetupPinOptions(14, GPIO_OUTPUT, GPIO_ASYNC);
DINT;
InitPieCtrl();
//
// Disable CPU __interrupts and clear all CPU __interrupt flags:
//
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
scia_echoback_init(); // Initialize SCI for echoback
scia_fifo_init(); // Initialize the SCI FIFO
while(1)
{
scia_xmit('S'); us(100);
ms(10);
}
}
void scia_fifo_init(void)
{
//
// Note: Clocks were turned on to the SCIA peripheral
// in the InitSysCtrl() function
//
EALLOW;
SciaRegs.SCIFFTX.all = 0xE040;
SciaRegs.SCIFFRX.all = 0x2044;
SciaRegs.SCIFFCT.all = 0x0;
return;
}
//
// scia_xmit - Transmit a character from the SCI
//
void scia_xmit(int a)
{
while (ScibRegs.SCIFFTX.bit.TXFFST != 0) {}
ScibRegs.SCITXBUF.all =a;
}
//
// scia_msg - Transmit message via SCIA
//
void scia_msg(char * msg)
{
int i;
i = 0;
while(msg[i] != '\0')
{
scia_xmit(msg[i]);
i++;
}
}
//
// scia_fifo_init - Initialize the SCI FIFO
//
// End of file
//
void scia_echoback_init(void)
{
EALLOW;
//
// Note: Clocks were turned on to the SCIA peripheral
// in the InitSysCtrl() function
//
ScibRegs.SCICCR.all = 0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
ScibRegs.SCICTL1.all = 0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
//ScibRegs.SCICTL2.all = 0x0003;
//ScibRegs.SCICTL2.bit.TXINTENA = 1;
//ScibRegs.SCICTL2.bit.RXBKINTENA = 1;
//
// SCIA at 9600 baud
// @LSPCLK = 50 MHz (200 MHz SYSCLK) HBAUD = 0x02 and LBAUD = 0x8B.
// @LSPCLK = 30 MHz (120 MHz SYSCLK) HBAUD = 0x01 and LBAUD = 0x86.
//
ScibRegs.SCIHBAUD.all = 0x000B; // 0x0002;
ScibRegs.SCILBAUD.all = 0x009E; // 0x008b;
ScibRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
}