4 Replies Latest reply on Mar 7, 2016 7:47 AM by ByteMaster

    UART function Error in D2000

    ByteMaster

      Hi,

       

      I am trying this two functions (line 6 and 7) and both gave different results!

       

      #define MyString ("AT\r\n")
      
      .
      .
      .
      qm_uart_write_buffer(QM_UART_0, (uint8_t *)MyString, sizeof(MyString));
      QM_PRINTF("AT\r\n");
      

       

       

      qm_uart_write_buffer(QM_UART_0, (uint8_t *)aString, sizeof(aString)); output : AT\r\n0

      while QM_PRINTF("AT\r\n"); output : AT\r\n

       

      FYI, I have used QM_UART_LC_8N1 = 0x03,   /**< 8 data bits, no parity, 1 stop bit */ for Configuration. And there shouldn't be additional 0 at the end.

      Wasted few hours debugging hardware while apparently it was software error!!

        • 1. Re: UART function Error in D2000
          muhamad.soffi

          Hi ByteMaster,

           

          I tried to reproduce back your issue but it seem like there no issue on my machine. Could you try to repair/reinstall back the ISSM 2016 to see if the issue still persist. If yes, please help to provide more details on the setup to reproduce back the issue.

           

           

          Thanks.

          Soffi

          • 2. Re: UART function Error in D2000
            ByteMaster

            Hi Soffi,

            Try with Logic analyzer or oscilloscope..it appears in there.

            Thanks

            • 3. Re: UART function Error in D2000
              MichelleC_Intel

              Hi ,

               

              It seems you are also seeing the null character that marks the end of the string -- Do you see the same issue is you use strlen rather than sizeof to calculate the length ?

              It seems ok for me ..

               

              #include <qm_common.h>

              #include <qm_uart.h>

              #include <string.h>

               

              #define MyString ("AT\r\n")

               

              int main(void)

              {

              qm_uart_write_buffer(QM_UART_0, (uint8_t *)MyString, strlen(MyString));

              QM_PRINTF("AT\r\n");

              return 0;

              }

               

              regards,

              Michelle.

              • 4. Re: UART function Error in D2000
                ByteMaster

                Hi Michelle,

                 

                This make sense.

                it works with strlen instead of sizeof

                Please check the output of this three lines in attached pic.

                 

                 

                  qm_uart_write_buffer(QM_UART_0, (uint8_t *)MyString, sizeof(MyString));   /* Send "AT\r\n"  */

                  qm_uart_write_buffer(QM_UART_0, (uint8_t *)MyString, strlen(MyString));   /* Send "AT\r\n"  */

                  QM_PRINTF("AT\r\n");                                                                             /* Print "AT\r\n"  */

                 

                UART_0.jpg

                2 of 2 people found this helpful