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.

TMS320F28035: Ltoa function and scia_msg stuck sending characters

Part Number: TMS320F28035

Hello,

I'm currently working on a project and I'm using the SCI of the F28035 (standard) to send instructions to another microcontroller. The problem is when I use a the setChannel function (posted bellow) the SCI gets stuck after sending the first intruction "mac set ch status 8 on\r\n" (\0 is the stop character). When the function is called again to turn channel 9 on, the SCI sends '9on' characters almost non stop.

void setChannel(int channel){
    char *out;
    char chnn[2];
    ltoa(channel, chnn, 10);
    out = strcat("mac set ch status ", chnn);
    out = strcat(out, " on\r\n\0");
    scia_msg(out);
    }


 

The variable chnn used to be a char* but the function didn't recognize the buffer and the variable value never changed, so I changed to a char[2] and it worked but it introduced this new problem. did I program something wrong?.

Thanks in advance,

José.

  • Hi Jose,

    Instead of concatenating the strings together you can send them individually and it should work:

    void setChannel(int channel){
        char *out;
        char chnn[2];
        ltoa(channel, chnn);
        out = " mac set ch status ";
        scia_msg(out);
        scia_msg(chnn);
        out = " on\r\n\0";
        scia_msg(out);
        }

    Best Regards,

    Marlyn