1

Background Info I want to have two serials in my arduino nano rp2040 connect, in order to be able to communicate using the following scheme. (μC is a microcontroller).

μC1 <--> μC2 <--> μC3<-->....<-->μCn

So i tried changing the core and upload a sketch to test if it is possible. However, i ended up blocking the arduino, and

  1. it disappears from the COM port,
  2. the arduino red light is constantly blinking,
  3. the serial port of my computer freezes,
  4. the whole arduino application is not responding.
  5. The arduino disappears from the device manager and it ends up as a USB device.

I want to understand what causes it, in order to avoid doing it in the future.

I usually reset the board, and then i upload a Blink.ino.elf.uf2 i have previously compiled. The application gets unstuck, the arduino runs the blink programm, and it appears at COM4.

Changes i made to the core:

1st change

In

C:\Users\<user>\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\3.2.0\variants\NANO_RP2040_CONNECT

i changed the defines.txt and i changed the line:

-DDEVICE_SERIAL=1

to

-DDEVICE_SERIAL=2

2nd change

In the same folder, i changed pins_arduino.h in the following way:

// Serial
#define PIN_SERIAL_RX (0ul)
#define PIN_SERIAL_TX (1ul)

#define PIN_SERIAL2_RX (3ul)
#define PIN_SERIAL2_TX (4ul)

and

#define SERIAL_HOWMANY      2
#define SERIAL1_TX          (digitalPinToPinName(PIN_SERIAL_TX))
#define SERIAL1_RX          (digitalPinToPinName(PIN_SERIAL_RX))
#define SERIAL2_TX          (digitalPinToPinName(PIN_SERIAL2_TX))
#define SERIAL2_RX          (digitalPinToPinName(PIN_SERIAL2_RX))

My programm:

#define led LED_BUILTIN
char c;

void setup() {
  pinMode(led, OUTPUT);
  // put your setup code here, to run once:
  Serial.begin(9600);
  while(!Serial);
  digitalWrite(led,HIGH);
  delay(1000);
  digitalWrite(led,LOW);

  Serial2.begin(9600);
  while(!Serial2);
  digitalWrite(led,HIGH);
  delay(1000);
  digitalWrite(led,LOW);
  
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available() ){
    c = Serial.read();
    if (c != '\n'){
      Serial.print("Master wrote : ");
      Serial.println(c);
      Serial2.print(c);
    }
  }

  if (Serial2.available() ){
    c = Serial2.read();
    if (c != '\n'){
      Serial.print("Slave wrote : ");
      Serial.println(c);
    }
  }
delay(1000);
}

Edit I uploaded the same sketch with earlephilhower's core (you can find it here ) and the IDE showed this message:

Resetting COM4
Converting to uf2, output size: 136192, start address: 0x2000
Flashing D: (RPI-RP2)
Wrote 136192 bytes to D:/NEW.UF2
Board at COM4 is not available
Board at COM4 is not available

The last 2 messages were from me trying to open serial monitor. So i think the sketch has the problem, and not the modiffications i made to the mbed os core.

2
  • RP2040 has 2 UART peripherals. the datasheet has which pin can be used with which UART and in what direction. note that the datasheet has RP2040 pin numbering not the Nano pin numbering
    – Juraj
    Aug 25, 2022 at 17:18
  • I even used the phillower core without modifying anything, and i still faced the same problem. Also, the pinout or arduino rp2040 connect has one uart, so i do not know how to access the second uart that the rp2040 CPU has. From a link you sent me to another question, i understood that the second uart may not be accesible. Aug 26, 2022 at 21:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.