This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems sending string containing "0x0A" over RS232,

Hello everyone,

I am sending this string over serial, using KEIL ARM Uvision demo version :

"0x86 0x21 0x09 0x00 0x8D 0x0A 0x00 0x61 0x58"

And, when sending 0x0A, receive the corresponding ASCII character plus a 0x0D (enter). I do not want that enter !! I made my own putchar function, as seen on other posts, but it doesnÂ't work at all. Does anyone suffered the same problem ? Thanks in advance. Gabriel.-

  • Look at your function which sends character to the serial port.

    When for example printf, putc are used then retargeting of the fputc function is required which usually calls a function named sendchar. The adding of 0x0D after 0x0A is usually implemented in this function.

    Example for LPC2xxx:

    #define CR     0x0D
    
    int sendchar (int ch)  {                 /* Write character to Serial Port    */
    
      if (ch == '\n')  {
        while (!(U1LSR & 0x20));
        U1THR = CR;                          /* output CR */
      }
      while (!(U1LSR & 0x20));
      return (U1THR = ch);
    }
    

    You just need to get rid of the if statement in the above example.