I reviewed the codes, and it is quite 'convoluted'
when HardwareSerial initializes
https://github.com/stm32duino/Arduino_C ... l.cpp#L133
it configures the pins according to PeripheralPins.c
https://github.com/stm32duino/Arduino_C ... ins.c#L180
you can try using those pins, or if you like you can redefine them e.g. that PAxx 1st field in your local file. But they need to be valid hardware Rx, Tx pin going to the uart. so check the datasheets and ref manuals.
https://www.st.com/resource/en/datashee ... f405rg.pdf
This isn't the only way, you can also set them using
setRx() ,
setTx() in your sketch before calling
SerialN.begin(115200);.
in the same way it must be valid hardware Rx, Tx pins, check datasheet.
-----
that
Code: Select all
Serial4.setRx(PC11);
Serial4.setTx(PC10);
Serial4.begin(115200);
should work. in fact it is the same as that in PeripheralPins.c
https://github.com/stm32duino/Arduino_C ... ins.c#L180
uart3 is apparently on PB10, PB11 (not PC10, PC11), you can check in the datasheet table 9 alternate function mapping
(it is also the default mapping in PeripheralPins.c)
https://www.st.com/resource/en/datashee ... f405rg.pdf
I think the
Code: Select all
Serial4.setRx(PC11);
Serial4.setTx(PC10);
is after all needed as there are 2 possible uart4 configs (PA0 tx , PA1 rx) or (PC10 tx, PC11 rx)
setting them configures the pinMux when you call
SerialN.begin(115200) it looks up PeripheralPins.c and selects the entry from the correspondinig row.
-----
when you call
SerialN.begin(115200);, this is what happens.
it is actually HardwareSerial.begin( ... )
https://github.com/stm32duino/Arduino_C ... l.cpp#L390
then HardwareSerial.begin( ... ) in turns calls
https://github.com/stm32duino/Arduino_C ... l.cpp#L449
Code: Select all
_ready = uart_init(&_serial, (uint32_t)baud, databits, parity, stopbits, _rx_invert, _tx_invert, _data_invert);
that jumps here
https://github.com/stm32duino/Arduino_C ... art.c#L118
^ this code is important as it is where the uart is actually clocked and initialized.
so the initialization is done in
SerialN.begin(115200), if you want to change the pins, you need to call
setRx() ,
setTx(), before calling
SerialN.begin(115200) say in
void setup();