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
- it disappears from the COM port,
- the arduino red light is constantly blinking,
- the serial port of my computer freezes,
- the whole arduino application is not responding.
- 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.