Hi all.
Is here a kind person that can show or link me to an example, on how to remap USART1 TX/RX from PA9/PA10 to PB6/PB7 ?
platform = ststm32
board = genericSTM32F103C8
framework = arduino
Thanks in advance.
/Jens
Hi all.
Is here a kind person that can show or link me to an example, on how to remap USART1 TX/RX from PA9/PA10 to PB6/PB7 ?
platform = ststm32
board = genericSTM32F103C8
framework = arduino
Thanks in advance.
/Jens
This seems more like a usage question for the Arduino core you’re working with (which is GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino from your configuration).
Have you tried these functions
from the HardwareSerial
class which Serial
is an instance of?
#include <Arduino.h>
void setup() {
Serial.setRx(PB_7);
Serial.setTx(PB_6);
Serial.begin(115200);
}
void loop() {
Serial.println("Hello world");
delay(1000);
}
Hi maxgerhardt.
Thanks for your quick responce.
Sorry for the wrong Community
I have tryed your suggestion, except for one thing, I did not wrote an under score between PB_6/7 !!
I wrote:
Serial.setRx1(PB7);
Serial.setTx1(PB6);
Will try it out.
And move to Arduino core
Thanks a lot
/Jens
Both should be valid actually. PBx is an integer and goes into upper two function calls
wheras PB_x is a PinName
enum (source) and go into the lower two functions. The behavior should be the same.
You may also try for fun if it works when you create a custom Serial object
#include <Arduino.h>
HardwareSerial mySerial(PB7, PB6);
void setup() { mySerial.begin(115200); }
void loop() { mySerial.println("Hello"); delay(1000); }
If needs a custom variant with these settings changed, you can also create and use a custom variant with PlatformIO, see e.g. the example here.
Otherwise the STM32Duino people should be able to help you. (https://www.stm32duino.com/)
Hi maxgerhardt
People at the Arduino Core has solved my problem, actually you also did. Have I wrote the line HardwareSerial mySerial(PB7, PB6); as you suggested, and not as I did: HardwareSerial Serial1(PB7, PB6); it would have worked. Serial1 is a preformattered word as I understand it.
Thank you for pointing me in the right direction
/Jens