Dear all;
I am using F28027 and I am trying to make a communication on SCI between two DSP. Transmitter is transmitting the data. I have observed iton scope. However reciever is not receiving continuously. I have a delay loop in transmitter code and the longer I keep the delay time, the more receiver stuck on while condition to check flag. When I increase delay time code is waiting on while continuously, like there is no incoming data. When I make shorter delay time, it stuck less. Could someone tell me how to get rid of this problem. Here is my transmitter and receiver codes.
for(;;)
{
SendChar=0;
for (SendChar=1; SendChar<=255; SendChar++)
{
delay_loop();
scia_txmit(SendChar);
/*while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for XRDY =1 for empty state
// Check received character
ReceivedChar = SciaRegs.SCIRXBUF.all;
if(ReceivedChar != SendChar) error();
LoopCount++;*/
}
}
void scia_init()
{
//02.03.2017 SCI configuration for bluetooth
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; //enable pull-up for gpio28(SCIRXDA)
GpioCtrlRegs.GPAPUD.bit.GPIO29 = 1; //disable pull-up for gpio29(SCITXDA)
GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3; //asynch input GPIO28 (SCIRXDA)
GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1; //configure gppio as SCI transmitter
GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; //configure gppio as SCI reciever
EDIS;
SciaRegs.SCICCR.bit.STOPBITS = 0; //one stop bit
SciaRegs.SCICCR.bit.PARITYENA = 0; //disable parity
SciaRegs.SCICCR.bit.LOOPBKENA = 0; //loop back disable(when Tx connected internaly Rx)
SciaRegs.SCICCR.bit.ADDRIDLE_MODE = 0; //idle mode enable
SciaRegs.SCICCR.bit.SCICHAR = 7; //bith lenght is 8 bits
SciaRegs.SCICTL1.bit.TXENA = 1; //transmitter enable
SciaRegs.SCICTL1.bit.RXENA = 1; //receiver enable
SciaRegs.SCICTL2.bit.TXINTENA = 1; //Enable TXRDY interrupt
SciaRegs.SCICTL2.bit.RXBKINTENA = 1; //enable RXRDY interrupt
//örnekte ikikez yazılmış?
SciaRegs.SCIHBAUD = 0x0000;
SciaRegs.SCILBAUD = 0x000F; //LSPCLK = 12.5 MHz (50 MHz SYSCLK) baud=LSPCLK/(16*8)
SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
}
//transmitter function
void scia_txmit(int a)
{
SciaRegs.SCITXBUF = a;
}
void scia_fifo_init()
{
SciaRegs.SCIFFTX.all=0xE040;
SciaRegs.SCIFFRX.all=0x2044;
SciaRegs.SCIFFCT.all=0;
}
void delay_loop()
{
short i;
for (i = 0; i < 100; i++) {}
}
the code which is written above is for transmitter side.
I used timer interrupt for delay time but I had same problem.
For receiver side, I have described a variable named Received as uint8. Nevertheless, receiver dsp shows it as unsigned char. I want to learn why. and like I said before, it is stucking on while condition frequently (depends on delay time)
And here is receiver code
for(;;) {
//asm(" NOP"); // main loop (interrupt bekle)
SciaRegs.SCICTL1.bit.RXENA = 1;
while(SciaRegs.SCIRXST.bit.RXRDY == 0) { } // wait for XRDY =1 for empty state
//while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { }
// Get character
Received = SciaRegs.SCIRXBUF.all;
Received = Received & 0x00FF;
SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1;
//asm (" NOP");
//SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1;
}
void scia_init()
{
//02.03.2017 SCI configuration for bluetooth
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; //enable pull-up for gpio28(SCIRXDA)
//GpioCtrlRegs.GPAPUD.bit.GPIO29 = 1; //disable pull-up for gpio29(SCITXDA)
GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3; //asynch input GPIO28 (SCIRXDA)
GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1; //configure gppio as SCI reciever
//GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; //configure gppio as SCI transmitter
EDIS;
SciaRegs.SCICCR.bit.STOPBITS = 0; //one stop bit
SciaRegs.SCICCR.bit.PARITYENA = 0; //disable parity
SciaRegs.SCICCR.bit.LOOPBKENA = 0; //loop back disable(when Tx connected internaly Rx)
SciaRegs.SCICCR.bit.ADDRIDLE_MODE = 0; //idle mode enable
SciaRegs.SCICCR.bit.SCICHAR = 7; //bith lenght is 8 bits
//SciaRegs.SCICTL1.bit.TXENA = 1; //transmitter enable
SciaRegs.SCICTL1.all = 0x0001; //receiver enable
//SciaRegs.SCICTL2.bit.TXINTENA = 1; //Enable TXRDY interrupt
SciaRegs.SCICTL2.all = 0x0002; //enable RXRDY interrupt
//örnekte ikikez yazılmış?
//autobaud detection(14.03.2017)
SciaRegs.SCIFFCT.bit.CDC = 1; //Enable aoutoboaud aligment
SciaRegs.SCIFFCT.bit.ABDCLR = 1; //clear abd bit
SciaRegs.SCIHBAUD = 0x0000; //selact a baud speed below 500 kbps
SciaRegs.SCILBAUD = 0x0001; //LSPCLK = 12.5 MHz (50 MHz SYSCLK) baud=LSPCLK/(16*8)
//SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
SciaRegs.SCICTL1.all =0x0021; // Relinquish SCI from Reset
//SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1; //enable fifo tx interrupt so as to disable autobaud
}
void scia_fifo_init()
{
SciaRegs.SCIFFTX.all=0xE040;
SciaRegs.SCIFFRX.all=0x2044;
SciaRegs.SCIFFCT.all=0x0;
}
I will be glade if someone help me immediately.
Thanks a lot.
Regards
Fahri