This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Issue with serial communication with the SCI port

Greetings,

I am using the F28335 and I am having and issue with transmitting from GPIO 28/29 to 18/19.  I am able to send a message from that is received by GPIO 28 and then passed along to GPIO 18.  When I do this the message is passed along but a <null> is attached to the message.

you can see what the oscilloscope shows too here:

You can see that the blue signal has a different last character than the yellow signal.  This is where I believe the null comes from.

When I transmit the other way from 19 to 29 the message is sent correctly.

Here is what the scope looks like for this one:

Here is the code I use to transmit.

28 to 18:

void SCIxConsoleTx(void){
//---------------------------------------------------------------------------
Uint16 done;


if(Console_Flags.bit.b_en == 1){
done = 0;
while(done != 1){
if(Msg_Flags.bit.scib_tx_rdy == 1){
ScibRegs.SCITXBUF = tx_buff_b[Console_Flags.bit.b_tx_index];
Msg_Flags.bit.scib_tx_rdy = 0;
ScibRegs.SCIFFTX.bit.TXFFINTCLR = 1;
done = 1;
}
}
}

else if(Console_Flags.bit.c_en ==1){
done = 0;
while(done != 1){
if(Msg_Flags.bit.scic_tx_rdy == 1){
ScicRegs.SCITXBUF = tx_buff_c[Console_Flags.bit.c_tx_index];
Msg_Flags.bit.scic_tx_rdy = 0;
ScicRegs.SCIFFTX.bit.TXFFINTCLR = 1;
done = 1;
}
}
}
else{
SciaTx(String_err);
}

}

when a message comes from Gpio19 and goes to 29:

the inputs to this is

char c= 'B';

and 

char *ptr = &rx_buff_b[Console_Flags.bit.b_rx_index];

void SciaTxScixByte(char c, char *ptr){
//---------------------------------------------------------------------------
Uint16 i;
Uint16 n;
char ph[5];
char x[2];

if(c == 'B')
i = index_b;
else if(c == 'C')
i = index_c;
else{
SciaTx(String_err);
SciaTx(": invalid channel");
return;
}

String_SCI_Byte[8]= c;
snprintf(ph,4, "%.4d",i);
for(n=0;n<4;n++){
String_SCI_Byte[n]=ph[n];
}

x[0] = *ptr;
x[1] = 0;
SciaTx(x);

}

void SciaTx(const char message[]){
//---------------------------------------------------------------------------
Uint16 i,ph,len, done;
len = strlen(message);
ph = done = 0;
if(len <= 0x0F){ //if the message fits in the register
while(done != 1){
if(Msg_Flags.bit.scia_tx_rdy == 1){ //scia is ready to transmit
for(i=0;i<len;i++)
SciaRegs.SCITXBUF = message[i]; //put the characters in the buffer
Msg_Flags.bit.scia_tx_rdy = 0; //indicate buffer is full, interrupt will set when done
SciaRegs.SCIFFTX.bit.TXFFINTCLR = 1;//clear interrupt flag
done = 1; //indicate done
}
}
}
else{
while(done != 1){
if(Msg_Flags.bit.scia_tx_rdy == 1){
for(i=ph;i<0x10+ph;i++)
SciaRegs.SCITXBUF = message[i];
ph+=0x10;
Msg_Flags.bit.scia_tx_rdy = 0;
SciaRegs.SCIFFTX.bit.TXFFINTCLR = 1;
if((len-ph)/16 < 1)
done = 1;
}
}
done = 0;
while(done != 1){
if(Msg_Flags.bit.scia_tx_rdy == 1){
for(i=ph;i<len;i++)
SciaRegs.SCITXBUF = message[i];
Msg_Flags.bit.scia_tx_rdy = 0;
SciaRegs.SCIFFTX.bit.TXFFINTCLR = 1;
done = 1;
}
}

}

}

any pointers would be apreciated.

  • Hi,

    Try using a carriage return ''/r"

    Regards,

    Gautam

  • Since the message is already in the buffer where would I add the carriage return? 

  • Ok, so while receiving did you filter out the null character?

    for eg: if(x[buff] != '\0') ....proceed

    In this way You'll be able to filter it out!

    Regards,

    Gautam

  • I did not.  I'm wondering if there is something going on during the interrupt service.  I can try that though.

    interrupt void SCIRXINTA_ISR(void) // SCI-A
    {
    Uint16 i;

    command[length] = SciaRegs.SCIRXBUF.bit.RXDT;
    // To receive more interrupts from this PIE group, acknowledge this interrupt
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;
    SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1;
    //check if <CR><LF> was received
    if(command[length] == 0x0A)//new line (n)
    if(command[length-1] == 0x0D){//Return (r)
    Msg_Flags.bit.scia_rx_rdy = 1;
    for(i=0;i<70;i++){
    command[i+length-1]=0;
    }
    //command[length]=0x0A;
    //command[length-1]= 0x00;

    length = 0xFFFF; //reset the length counter
    }

    if(Console_Flags.bit.b_en == 1){

    //if(strcmp(command,"<NUL>"))
    //command[5]=0x0D;
    // command[length-3]=0x0D;

    Console_Flags.bit.b_tx_index = ~Console_Flags.bit.b_tx_index;
    tx_buff_b[Console_Flags.bit.b_tx_index] = command[length];
    Console_Flags.bit.b_tx_pend = 1;
    }
    if(Console_Flags.bit.c_en == 1){
    Console_Flags.bit.c_tx_index = ~Console_Flags.bit.c_tx_index;
    tx_buff_c[Console_Flags.bit.c_tx_index] = command[length];
    Console_Flags.bit.c_tx_pend = 1;
    }

    length++;
    if(length > 70){
    length = 0;
    }
    }

  • So I played around with the code a little bit and I changed this little section here:

    if(Console_Flags.bit.b_en == 1){

    Console_Flags.bit.b_tx_index = ~Console_Flags.bit.b_tx_index;
    tx_buff_b[Console_Flags.bit.b_tx_index] = SciaRegs.SCIRXBUF.bit.RXDT;
    Console_Flags.bit.b_tx_pend = 1;

    }

    By changing the code I got rid of the mode but the output still isn't 100% right.  When I send the command test it sends IO18/1 over instead of the message test.  If i send test again 9-star.  A third time results in <CR><LF> TES.  Is there a way to clear the buffer so that I can send the correct message?

    Send test again