STM32F405 and UART4 compiling problem #1556
-
Core 2.1.0 I'm developing a board with a STM32F405ZGT6 processor. I'm using the variant "GenericF407ZGTx" because it has the pheripherals that I need. I need Serial1, Serial4 and Serial5, so I wrote the declaration code in this way: // RX TX // RX TX // RX TX But, if I compile the code, the copiler tells me that Serial4 is already declared in HardwareSerial.cpp. So I opened te file variant_generic.h (under hardware\stm32\2.1.0\variants\STM32F4xx\F407Z(E-G)T and changed the line: in: // UART Definitions In this way, sketch compiles and serial is running. What is the purpose of this define? Best regards. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @luca-stm32 Serial.setRx(PC11);
Serial.setTx(PC10);
Serial.begin(9600); ref: https://github.com/stm32duino/wiki/wiki/API#hardwareserial |
Beta Was this translation helpful? Give feedback.
Hi @luca-stm32
in fact the generic define the
SERIAL_UART_INSTANCE
to be the default Serial instance.In that case
Serial4
is instantiate by default and mapped toSerial4
and using default pins:PA1
/PA0
.So you don't need to instantiate
Serial4
but as you needPC11
/PC10
simply change it using thesetRx()
andsetTx()
before thebegin()
:Serial.setRx(PC11); Serial.setTx(PC10); Serial.begin(9600);
ref: https://github.com/stm32duino/wiki/wiki/API#hardwareserial