Serial0.print hangs with UART5 + UART2 plugged

Discussion in 'UDOO NEO' started by Gorgo, Nov 23, 2016.

  1. Gorgo

    Gorgo UDOOer

    Joined:
    Nov 9, 2016
    Messages:
    158
    Likes Received:
    17
    Hi guys!

    Problem:
    Sketch hangs when I use Serial0 + 5V+3.3V sensors. I had to remove the sketch file and reboot in order to upload a new one. (UDOONeo M4 Sketch STOP failed: reboot system !)

    My configuration:
    - Udoo Neo Full
    - RTC + Pressure sensors + GPS (3.3V)
    - Pollution + DHT (5V)
    - 12V power supplier

    If I pin both 5V and 3.3V on my breadboard, the sketch starts printing and it stops eventually after 5/6 prints. If I only plug one set of them (3.3 or 5), it works, the Serial0 doesn't stop.

    The pollution sensor writes to Serial0 RX pin (UART5) while the DHT sensor is linked to GPIO_140.

    On 3.3V side, the RCT SDA/SCL is linked to UDOO SDA/SCL, RCT SQW to GPIO_124; GPS 3.3V input/ground with the breadboard and from the sensor towards GPIO_6 and GPIO_7 (UART2). The pressure sensor is on the same row of the RTC. Even SDA/SCL they're connected to Udoo SDA/SCL.


    Sketch:
    Code:
    #define LENG 31
    unsigned char buf[LENG];
    
    void setup(){
      Serial.begin(115200); //Serial is Linux side
      Serial.println("Serial begin OK...");
    
      Serial0.begin(9600);
      Serial0.setTimeout(1500);
    }
    
    void loop(){
      byte b=0;
      while(b != 0x42){
        b = Serial0.read();
        delay(100);
      }
      Serial0.readBytes(buf,LENG);
      Serial.println("Loop...");
      Serial.flush();
      delay(500);
    }
     
    Last edited: Nov 23, 2016
  2. Gorgo

    Gorgo UDOOer

    Joined:
    Nov 9, 2016
    Messages:
    158
    Likes Received:
    17
    Ok Update:
    The guilty sensor seems to be the pressure one.
    If it has power but it's not connected to UDOO, the sketch keeps running.
    I I plug it to GPIO 6 and 7 (UART2_TX and UART2_RX) it hangs.
    Is there a conflict between Serial0 and UART2 an UART5?


    Edit:
    the guilty sensor is definitely the GPS SENSOR.
    Pin recap: at the moment it's powered with 3.3V it communicates to UART2 (GPIO_6 and 7).
    If both pollution (that communicates to UART5) and GPS are plugged with UARTs, the sketch hangs if I use Serial0.
    If I unplugged GPS's pins to UART2, the sketch works.

    At this very moment, I swapped GPS TX/RX, the sketch works, but I have to check if GPS is working fine.

    The question remains: Why this behaviour if I'm using both UARTs? Am I missing something?
     
    Last edited: Nov 23, 2016
  3. Gorgo

    Gorgo UDOOer

    Joined:
    Nov 9, 2016
    Messages:
    158
    Likes Received:
    17
    I've edited my previous message with new details.
     
  4. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    I've only used both UARTs in a simple test program, where the Neo was the sender and the Mega was the receiver. I have had it running for quite a while and I had no problems.

    However, I'll be using Mega<->M4<->iMX.6 communication soon. If I run into something I'm sure to post it at this forum.
     
  5. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,295
    Likes Received:
    565
    According this documentation UART2 is only for debugging the M4 so connecting devices to this serial could have strange effects. How are you reading this serial in your sketch?

    Also using 5V is dangerous for the Neo as the Neo is a 3.3V board.
     
  6. Gorgo

    Gorgo UDOOer

    Joined:
    Nov 9, 2016
    Messages:
    158
    Likes Received:
    17
  7. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,295
    Likes Received:
    565
    As long as the 5V powered sensor is not sending 5V signals out there is no issue. But normally they don't unless they have a 3.3V/5V switch.
     

Share This Page