Go Down

Topic: Serial uart commuication problem (Read 517 times) previous topic - next topic

vannue

Hi all,

We've been troubleshooting our 2 MKR1000 boards as they show both the same result/fault.

We've got a working program and custommade shields for the uno where a lcd screen of 4D systems using the serial 0,1 communication between the board and the display.

Now we created a new shield for the MKR1000, changed the Serial to Serial1 in the code and the port 13,14 for the rx tx communication to the display.
It ended up that nothing happens when we write something to the display. We've hooked on a logic analyser and nothing was send from the MKR to the Display but we receive commands from the display to the MKR.

This is the first odd thing. So we did a simple test to see if the MKR (all 2 of them have the same issue)

When I upload the following code the LED will burn 12 times and then stops with blinking.

Code: [Select]
void setup() {
  // put your setup code here, to run once:
Serial1.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(LED_BUILTIN, LOW);
Serial1.write("hello");
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
delay(250);
}


If I do the same with the uno and MKR the LED will blink for hours and we receive messages on the serial monitor (MKR and UNO) and on the uno when we connect the logic analyser (it's not possible for the MKR as the serial is connected to the usb)

Code: [Select]
void setup() {
  // put your setup code here, to run once:
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(LED_BUILTIN, LOW);
Serial.write("hello");
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
delay(250);
}


Did we do something wrong or did we missed something? Or does anyone has the same issue


P.s.:
For those who are intrested here's the code of the test program we made for the display interaction which fails with the MKR including a Debug led so that we can track if the board is freezing or not and that the code is working

Code: [Select]
//Test Screen MKR1000

#include "genieArduino.h"
//#include <SPI.h>

Genie genie;
#define RESETLINE 4

//program definitions
bool buttonLive;        //Definition button on screen
bool buttonCalibration;   //Definition button on screen
bool buttonScope;      //Definition button on screen
bool firstReading;
float OffsetLive;

void setup() {
  Serial1.begin(115200);  // Serial0 @ 200000 (200K) Baud
  genie.Begin(Serial1);   // Use Serial0 for talking to the Genie Library, and to the 4D Systems display. Serial for uno, Serila1 for mkr
   
  genie.AttachEventHandler(myGenieEventHandler); // Attach the user function Event Handler for processing events

  // Reset the Display (change D4 to D2 if you have original 4D Arduino Adaptor)
  // THIS IS IMPORTANT AND CAN PREVENT OUT OF SYNC ISSUES, SLOW SPEED RESPONSE ETC
  // If NOT using a 4D Arduino Adaptor, digitalWrites must be reversed as Display Reset is Active Low, and
  // the 4D Arduino Adaptors invert this signal so must be Active High.
  pinMode(RESETLINE, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
  digitalWrite(RESETLINE, 1);  // Reset the Display via D4
  delay(100);
  digitalWrite(RESETLINE, 0);  // unReset the Display via D4

  delay (5000); //let the display start up after the reset (This is important) was before 3500

  // Set the brightness/Contrast of the Display - (Not needed but illustrates how)
  // Most Displays, 1 = Display ON, 0 = Display OFF. See below for exceptions and for DIABLO16 displays.
  // For uLCD-43, uLCD-220RD, uLCD-70DT, and uLCD-35DT, use 0-15 for Brightness Control, where 0 = Display OFF, though to 15 = Max Brightness ON.
  genie.WriteContrast(15);

  //program settings
  buttonLive = 0; // Initialise buttonLive in 0 mode
  buttonCalibration = 0; // Initialise buttonCalibration in 0 mode
  buttonScope = 0;  // Initialise buttonScoop in 0 mode

  //Debug led
  pinMode(11, OUTPUT);
 
  digitalWrite(11, LOW);
}

void loop() {
  genie.DoEvents(); // This calls the library each loop to process the queued responses from the display
  if (buttonLive == 1) // If button "live meting" is "active" then start liveMeasure
  {
    liveMeasure();
  }
  if (buttonCalibration == 1) // If button "Calibration" op "on" then start Calibration
  {
    Calibration();
  }
  if (buttonScope == 1) //If button "Scope" op "Active" then start Scope
  {
    Scope();
  }

}

void myGenieEventHandler(void)
{
  genieFrame Event;
  genie.DequeueEvent(&Event); // Remove the next queued event from the buffer, and process it below

  //If the cmd received is from a Reported Event (Events triggered from the Events tab of Workshop4 objects)
  if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
  {
    if (Event.reportObject.object == GENIE_OBJ_WINBUTTON)
    {
      if (Event.reportObject.index == 4)    // Live measure 4 due to winbutton6 in 4workshop
      {
        buttonLive = !buttonLive;           // switch state buttonLive with each press between 1 and 0
      }
      if (Event.reportObject.index == 3)      //When pressing on main menu in live screen we go back to main menu and reinitialise the start state
      {
        genie.WriteObject(GENIE_OBJ_FORM, 0, 0);
        buttonLive = 0;                       //Set state of winbutton4 to start state and buttonLive to 0
        genie.WriteObject(GENIE_OBJ_WINBUTTON, 4, 0);
        firstReading = true;                  //firstReading reinitaliseto True for next measurement
      }
      if (Event.reportObject.index == 8)    // Calibration mode active 8 because of  winbutton8 in 4workshop
      {
        buttonCalibration = !buttonCalibration;           // switch state buttonCalibration with each press between 1 and 0
      }
      if (Event.reportObject.index == 7)      //When pressing on main menu in live screen we go back to main menu and reinitialise the start state
      {
        genie.WriteObject(GENIE_OBJ_FORM, 0, 0);
        buttonCalibration = 0;                       //Set winbutton8 state back to start and buttonCalibration to 0
        genie.WriteObject(GENIE_OBJ_WINBUTTON, 8, 0);
      }
      if (Event.reportObject.index == 5)      //When pressing on main menu in fft screen we go back to main menu and reinitialise the start state
      {
        genie.WriteObject(GENIE_OBJ_FORM, 0, 0);
        //buttonFFT = 0;                       //en zetten we winbutton8 terug naar de beginstatus alsook buttonLive to 0
        genie.WriteObject(GENIE_OBJ_WINBUTTON, 6, 0);
      }
      if (Event.reportObject.index == 10)    // Calibration mode actief 8 omwille van winbutton8 in 4workshop
      {
        buttonScope = !buttonScope;           // switch state  buttonScope  with each press between 1 and 0
      }
      if (Event.reportObject.index == 9)      //When pressing on main menu in Scope screen we go back to main menu and reinitialise the start state
      {
        genie.WriteObject(GENIE_OBJ_FORM, 0, 0);
        buttonScope = 0;                       //Set state winbutton10 back to the start and buttonScope to 0
        genie.WriteObject(GENIE_OBJ_WINBUTTON, 10, 0);
      }
    }
  }
}

void liveMeasure()
{
  genie.WriteObject(GENIE_OBJ_METER, 0, 25);
  digitalWrite(11, HIGH);
}
void Calibration()
{
  genie.WriteObject(GENIE_OBJ_METER, 1, 100);
}
void Scope()
{
  genie.WriteObject(GENIE_OBJ_SCOPE, 0, 1236.5);
}

vannue

You may delete this. I just found out that the 4Ds shield was causing problems as this has also a usb to uart communication to program the display.

This interfere with the MKR1000 USB to serial on-board chip

Go Up