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.

LAUNCHXL-F280049C: Sending integer values through SCI

Part Number: LAUNCHXL-F280049C
Other Parts Discussed in Thread: C2000WARE

I am trying to send a message repeatedly from SCI with an integer value counting up. The messages should look like this: 

"The number is 0

The number is 1

The number is 2

..."

What I have so far is this:
int n = 0;
unsigned char *msg;
msg = "\r\nThe number is";
for(;;)
{
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 15);
?????
n++;
}

Which function should I use for the line I marked ????? in order to send the value of n? All library functions for SCI are for sending chars. I tried including "stdlib.h" and using the itoa() function, but it doesn't work for some reason returning the error: 

unresolved symbol _itoa, first referenced in ./main.obj 

#include "stdlib.h"
...
void main(void){
... //Initialize SCI int n = 0; unsigned char *val; unsigned char *msg; while(1) { msg = "\r\nNo: "; SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 4); itoa(n, val, 10); SCI_writeCharArray(SCIA_BASE, (uint16_t*)val, sizeof(val)); n++; } }

I also tried using sprintf to create a new string but it didn't work either. Is there a simple way of including an integer into the message sent by SCI?





  • Nesli,

    Please see our F28004x SCI example code, which can be found at:

    C:\ti\c2000\C2000Ware_<version>\driverlib\f28004x\examples\sci

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks

    - Ken
  • I already checked all three of the sci examples, but again they are for receiving and sending chars. For example:

    //code from SCI interrupt echoback example.
    
    uint16_t receivedChar;
    receivedChar = SCI_readCharBlockingNonFIFO(SCIA_BASE);
    
    //
    // Echo back the character.
    //
    msg = "  You sent: \0";
    SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 13);
    SCI_writeCharBlockingNonFIFO(SCIA_BASE, receivedChar);

    From what I understand, by using this code I am only able to send/receive one char, which means if I want to send numbers with more than one digit I'd have to check how many digits the number has and call SCI_writeCharBlockingNonFIFO() for each of the digits. I am looking for a simpler way than that if it exists, since the number I want to print can have several digits.

  • Nesli,

    Yes, you are correct. The SCI sends/receives one character at a time. To send/receive multiple characters you can use the FIFOs. You would need to manage the number of characters by configuring the FIFO registers.

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks

    - Ken