Part Number: TMS320F28377D
Other Parts Discussed in Thread: C2000WARE
Dear team:
One of my customers had a problem using SCI polling receive mode:
Uint16 scid_read(void)
{
Uint16 rtn=0;
while(ScidRegs.SCIFFRX.bit.RXFFST == 0);
rtn = ScidRegs.SCIRXBUF.all;
// while(ScidRegs.SCIFFRX.bit.RXFFST != 0)
// {
// rtn = ScidRegs.SCIRXBUF.all;
// }
return rtn;
}
If you use the above method, the chip can receive data. But the program will stop there.
If the following method is used, the chip cannot receive data. However, the data in the SCIRXBUF register can be seen to be changing during the simulation, indicating that it has been received. However, the condition of while(RXFFST != 0) cannot be passed.
void UART_GpioInit(void)
{
GPIO_SetupPinMux(77, GPIO_MUX_CPU1, 6);
GPIO_SetupPinOptions(77, GPIO_INPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(76, GPIO_MUX_CPU1, 6);
GPIO_SetupPinOptions(76, GPIO_OUTPUT, GPIO_ASYNC);
}
void scid_init(Uint32 baud)
{
//
// Note: Clocks were turned on to the SCIA peripheral
// in the InitSysCtrl() function
//
Uint16 brr;
Uint16 brrh,brrl;
ScidRegs.SCICCR.all = 0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
ScidRegs.SCICTL1.all = 0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
ScidRegs.SCICTL2.all = 0x0000;
ScidRegs.SCICTL2.bit.TXINTENA = 0;
ScidRegs.SCICTL2.bit.RXBKINTENA = 0;
brr=(Uint16)(50000000/(baud*8)-1);//低速时钟50MHz
brrh = brr>>8;
brrl = brr & 0xff;
ScidRegs.SCIHBAUD.all = 0x0002;//9600
ScidRegs.SCILBAUD.all = 0x008B;
ScidRegs.SCICCR.bit.LOOPBKENA = 0; // Enable loop back
ScidRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
}
void scid_fifo_init()
{
ScidRegs.SCIFFTX.all = 0xE040;//初始化发送缓冲寄存器
ScidRegs.SCIFFRX.all = 0x2040;//接收缓冲寄存器0个levle
ScidRegs.SCIFFCT.all = 0x0;
}
while(1)
{
read_data = scid_read();
}
Best Regards