Hi,
I have successfully send/transmit characters before through SCI-A TX, thanks to the support
Now I'm trying to read characters through the receive line SCI-A RX.
The source will always keep sending "abcdefg\r\n\0"
So if I view it via terminal, it will go like this:
abcdefg
abcdefg
abcdefg
..
..
..
abcdefg
I'm trying to read the characters one by one via SCI-A RX and stop reading after a full "abcdefg" successful read.
This is my code so far:
interrupt void scia_rx_isr(void)
{
for ( ; ;)
{
while (SciaRegs.SCIFFRX.bit.RXFIFST == 0)
receivedchar = SciaRegs.SCIRXBUF.all;
tempbuffer[i++] = receivedchar;
if(receivedchar == '\r')
break;
SciaRegs.SCIFFRX.bit.RXFFOVRCLR = 1; // clear overflow flag
SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1; // clear interrupt flag
PieCtrlRegs.PIEACK.all |= 0x100; // issue PIE ack
}
void scia_rs485_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 //RIGHT NOW ONLY RX
//disable RX ERR, SLEEP, TX WAKE
SciaRegs.SCICTL2.all = 0x0003; //enable RX INTRPT, TX INTRPT
SciaRegs.SCICTL2.bit.TXINTENA = 1;
SciaRegs.SCICTL2.bit.RXBKINTENA = 1;
SciaRegs.SCIHBAUD = 0x0000;
SciaRegs.SCILBAUD = 0x0006;
SciaRegs.SCICCR.bit.LOOPBKENA = 0; //disabled loop back
SciaRegs.SCIFFTX.all = 0xC028; //SCI resume transit/receive, SCI FIFO enable, transmit FIFO intrpt enable, (01000) intrpt level bits
SciaRegs.SCIFFRX.all = 0x0021; //receive FIFO intrpt enable, (00001) intrpt level bits
SciaRegs.SCIFFCT.all = 0x00;
SciaRegs.SCICTL1.all = 0x0023; //relinquish SCI from reset
SciaRegs.SCIFFTX.bit.TXFIFOXRESET = 1; //re-enable transmit FIFO operation
SciaRegs.SCIFFRX.bit.RXFIFORESET = 1; //re-enable receive FIFO operation
}
Seems like I'm not getting the correct character and the chracater inside receivedchar won't change either.
Any help will be greatly appreciated.
Thank you