9 Replies Latest reply on Jul 12, 2017 6:05 PM by Intel Corporation

    UART sensitivity of Edison for Arduino

    cyrillicsoft

      Hello everyone!

      I am using an Intel Edison board for Arduino which is connected to an ITEAD Nextion HMI by a UART cable.

      It looks like the Nextion HMI gives off some noise during transmission. The width of this noise is minimal and negligible.

      Nevertheless, Edison's UART interprets this noise as data, when it must actually ignore it because the noise is too tiny.

       

      To demonstrate this, I prepared a test program and used a Saleae logic analyzer with a sample rate of 500 MS/s to see what was going on.

      The analyzer was able to catch some of these noise signals, but others were too small for it to even notice.

      But still, Edison's UART thinks these noise signals are data and proceeds to fill its buffer with rubbish 0xFF bytes.

      I've included a test program below and enclosed materials which illustrate how it works.

       

      HOW CAN I POSSIBLY AVOID THIS EFFECT WHICH HAS PROVEN TO BE A REAL NUISANCE?

       

      ***Source code***

       

       

       

      checkFF (){


           unsigned int er;

           char* buf_w;

       

           char rx_buf[400] __attribute__ ((aligned (4))) ={0} ;

           char rx_buf1[400] __attribute__ ((aligned (4))) ={0};

           char rx_buf2[400] __attribute__ ((aligned (4))) ={0};

       

           char startFF[]="\xFF\xFF\xFF";

           char connect[]="con_nect.val=1\xFF\xFF\xFF";

       

       

       

           mraa_init();

           mraa_uart_context m_uart = mraa_uart_init(0);

           er= mraa_uart_set_baudrate(m_uart,9600);

           er= mraa_uart_set_mode(m_uart,8,MRAA_UART_PARITY_NONE,1);

           er= mraa_uart_set_flowcontrol (m_uart,false,false);

           er= mraa_uart_set_non_blocking (m_uart,false);

       

       

       

      // Read everything that appears after program start and Initialization of UART

       

           buf_w = rx_buf2 + 4;

           while(er){

                if(mraa_uart_data_available (m_uart,1000)){

                     er =  mraa_uart_read(m_uart,buf_w,200);

                     if(er==0xFFFFFFFF){break;}

                     buf_w +=er;

                }

                else{break;}

           }

           // first word of buffer <- total length of reading

           *((int*)(rx_buf2)) = buf_w - rx_buf2 - 4; // Total length of input bytes

       

      /* BREAKPOINT 2

       

      Send 0xFFFFFF to Nextion to close the previous transmission

       

      Nextion will send 0x00FFFFFF  i.e. "Invalid instruction" reply

      */

       

           er=mraa_uart_write(m_uart, startFF, sizeof(startFF)-1);

       

           buf_w = rx_buf1 + 4;

           while(er){

                if(mraa_uart_data_available (m_uart,1000)){

                     er =  mraa_uart_read(m_uart,buf_w,200);

                     if(er==0xFFFFFFFF){break;}

                     buf_w +=er;

                }

                else{break;}

           }

           // first word of buffer <- total length of reading

           *((int*)(rx_buf1)) = buf_w - rx_buf1 - 4; // Total length of input bytes

       

       

       

      /* BREAKPOINT 3

       

      Send Nextion the command "con_nect.val=1/0xff/0xff/0ff" (simple variable assignment)

       

      Nextion will reply with 0x66000000

      */

       

           er=mraa_uart_write(m_uart, connect, sizeof(connect)-1);

       

           buf_w = rx_buf + 4;

           while(er){

                if(mraa_uart_data_available (m_uart,1000)){

                     er =  mraa_uart_read(m_uart,buf_w,200);

                     if(er==0xFFFFFFFF){break;}

                     buf_w +=er;

                }

                else{break;}

           }

           // first word of buffer <- total length of reading

           *((int*)(rx_buf)) = buf_w - rx_buf - 4; // Total length of input bytes

           er = mraa_uart_stop(m_uart);

       

           mraa_deinit();

       

       

      // BREAKPOINT 4

           return;