-
Hi, I have recently bought a NUCLEO-L412KB for the purpose of proxying USART packets between 2 devices and intercepting + modifying certain packets. I am confused a bit confused: In the microprocessor documentation, it is said to have 3 USARTs, but looking at the pinout for the devboard, I can see only 2 USARTS, and from my understanding USART2 is reserved for the USB serial monitor, so how come I only get 1 USART in the end for communication? Can someone help me out here? (I suppose I can refrain from using the serial monitor, that will allow me to have 2 USARTs, enough for what I need, but will make debugging a lot more difficult). Is the missing USART3 something to do with the built-in STLink? Wouldn't it have its own dedicated pins? And if USART3 IS indeed being used for STLink communication, why isn't there a way to also send serial monitor messages through the STLink interface? (or is STLink strictly a programmer and nothing else?) Also, USART1 appears to have 2 TX lines, 2 RX lines, 3 RTS lines, and 3 CTS lines. I'm assuming that's just to allow a larger variety of pins when selecting which one to use for USART1? Thanks so much in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Being honest actually, I just remembered that the debugger exists. I suppose this could be a cool opportunity to learn to use it! |
Beta Was this translation helpful? Give feedback.
STM32L412KC has 2 USART (USART1 and USART2) and 1 LPUART1:
https://github.com/stm32duino/Arduino_Core_STM32/blob/01e4f0c9a8d20fc20125fd5be539a1ef3bf9d546/variants/STM32L4xx/L432K(B-C)U_L442KCU/PeripheralPins.c#L111C2-L130
By default USART2 is used for the VCP through the STLink using PA2 and PA15 pins.
This prevent to use LPUART1 as only PA2 offered LPUART1 TX.
As only 1 pin can be used for USART2 and LPUART1 TX you could not having 3 SERIAL at the same time. Anyway you can simply switch between then:
Serial2.end();
SerilaLP1.begin();
Serial.LP1.print("something");
SerilaLP1.end();
Serila2.begin();
...
https://github.com/stm32duino/Arduino_Core_STM32/wiki/API#hardwareserial