12 Replies Latest reply on Sep 8, 2016 5:48 PM by TonyMontes

    PROBLEM:Edison's UART behavior is diffrent when connected to different circuits.

    barlesh

      Hallo friends.

      Me again and my UART problems.

       

      I wrote a simple program to transmit a massage, every 3 seconds,  from my Edison via UART using mraalib.

       

      First I tried to send from my Edison to my computer using TTL to USB chip.

      When I’m connecting pins 0,1 & ground to a CP2102 USB to TTL and the CP2102 to my pc, and open serial terminal at my pc (screen /dev/ttyUSB0 38400 ),

      the massages is received and printed perfectly .

       

      Photo of the circuit:

      http://www.siz.co.il/my.php?i=2mmmyzzzutmz.jpg

      ScreenShot of screen's output.

      Siz - העלאת תמונות | פתיחת גלריות

       

       

      The Problem:

      After checking with single Edison, I want to communicate between two of them, connecting then via UART.

      When I connect pins 0,1 & ground of my Edison#1, to pins 1,0 & ground of my Edison#2 (rx#1->tx#2, tx#1->rx#2), the #2 Edison get something a bit different.

      I use mraa's read function constantly (polling), waiting for information to arrive (I can use data_available function before, but the results are the same).

      Then  I print to screen the Decimal value of every byte I get.

      The result is different then the first circuit.

       

      Photo of the circuit:

      http://www.siz.co.il/my.php?i=qnzzwyqzzgy5.jpg

      the printed received data is this:

      ScreenShot of output:

      Siz - העלאת תמונות | פתיחת גלריות

       

      As you can see, Edison#2 (receiver) get a lot of single Bytes with the value 10 (0b00001010, ASCII '\n') . it is received at the moment my first massage is sent from Edison#1 (transmitter).

      to be accurate, the amount of Decimal 10s I receive is few thousands (change every execution, but repeat itself - 5292 , 5300 or 7973 times).

      After receiving all the 10's, Edison#2 receive perfectly the 2nd massage sent from Edison#1, and then 3rd massage padded with decimal 0 before the massage. 4th massage is also OK accept for the added 0, and so on with 5,6, .....

      between every two massages, a single byte with Decimal 10 value is received at Edison#2.

       

       

      When I try to send the massage without '\n' between Edisons, the receiving Edison doesn’t receive anything. (at the first circuit Edison -> PC the massage received perfectly, and it is printed without  new line of course).

       

      My uart's initiation Function (at both edisons at circuit 2, and at the single edison of circuit 1):

      int init_modem(){

           if( (uart = mraa_uart_init(0)) == NULL   ){

                    exit(UART_ERROR);

           }

           if ( mraa_uart_set_baudrate(uart, UART_BOUD_RATE)!=MRAA_SUCCESS) {

                exit(UART_ERROR);

                }        //set uart boud rate [bps]

        if ( mraa_uart_set_mode(uart, 8,MRAA_UART_PARITY_NONE , 1)!=MRAA_SUCCESS) {

          }

       

        mraa_uart_set_flowcontrol(uart, 0, 0);

      return 1;

      }

       

      Full code is:

      port5_trans.c (for both circuit 1,2)

      https://github.com/barlesh/ISG/blob/master/UART/init_UART/port5_trans.c

      port5_trans.h

      ISG/port5_trans.h at master · barlesh/ISG · GitHub

       

      port5_rec.c (circuit 2).

      ISG/port5_rec.c at master · barlesh/ISG · GitHub

      port5_rec.h

      ISG/port5_rec.h at master · barlesh/ISG · GitHub

       

       

      Both The Edisons ware flashed recently (configure_edison --version output is 159).

       

      What can be the problem? What am I missing here?

      Why the results are perfect while using the USB-TTL chip but getting crazy when connecting directly?

       

      Thank you very much for you time & help. please let me know if I missed important information.

      Bar