Using Swan Serial2/3

New to Blues and new to this Forum. But reasonably experienced with Arduino and serial ports. I’m struggling to get spare UARTs (2 and 3) working on my Swan v3.0, which is plugged into Notecarrier F. All brand new.

I’ve found stuff like this:
HardwareSerial Serial2(PD_6, PA_2);
Serial2.begin() etc

But no luck. Searching this forum on this topic I also found this …

HardwareSerial Serial2(A5, A4);

or this …

HardwareSerial Serial2(PB6, PA2_ALT);

All compiled OK, but nothing actually worked for me (nothing out of Tx).

Can anyone help ?

Also, can anyone tell me where all these pins are defined ? I get PD6, PA2 (these are defined in the Swan data sheet), but PD_6, PA_2, A5, A4 ? I’m definitely missing something. What is the significance of the underscores ? And my Swan data sheet defines A4 and A5 as analog.

Hi @soupdragon welcome!

HardwareSerial Serial2(PD6, PA2);  // RX, TX

Will work fine, but the issue you will have with the Notecarrier F is that PD6 and PA2 are only exposed on the castellated edges of the Swan, which are not connected to the Notecarrier F unfortunately. Some other options you can try are:

HardwareSerial SerialUsart1(PA10,  PA9) // RX/TX
HardwareSerial SerialUsart2(PD6,  PA2) // RX2/TX2 castellations
HardwareSerial SerialUsart3(PB11,  PB10) // RX3/TX3 castellations

Were you hoping to access this additional UART via the Notecarrier F?

Thanks,
Alex

Thanks Alex, that is reassurring. I was on the right lines. However still no success. Full code below (minimal, based on Quickstart tutorial).

LED flash works and Serial.print ‘.’ works, but only for 63 cycles. Then the whole thing stops. Nothing ever from UART2. Maybe a flow control problem - so I tried tying RTS/CTS together, still no luck. (although I haven’t declared RTS/CTS pins anywhere, wasn’t sure how)

63 ‘.’ characters from the trusted Serial port is suspicious, suggesting we’ve hit a buffer limit and crashed when writing 64 or more characters to Serial2.

Longer term, if we ever did get one of these spare serial ports working, my hope would be to disable RTS/CTS flow control.

Many thanks in advance for any help you can offer,

John

#include <Arduino.h>

//HardwareSerial Serial2(PD6, PA2);
HardwareSerial SerialUsart2(PD6, PA2);

void setup() {
// put your setup code here, to run once:

// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);

delay(2500);
Serial.begin(115200);

// Swan serial2 experiments
SerialUsart2.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second

// Send something out of UART 2 (castellated pin PA2)
Serial.print(‘.’);
SerialUsart2.print(‘,’);
}

@soupdragon I believe you are right. The 63 cycles indicate a full buffer issue; It sounds like you are unable to read from SerialUsart2’s TX pin, where the expected character is ‘,’? I would guess that the TX buffer is filled at the point the code freezes.

I currently don’t have a way to attach a serial probe to the castellated edges of my Swan. I’ll check with a colleague and see if they can break out the castellated edges. I’ll see if I can check that this works for you.