Page 1 of 1

[SOLVED] HardwareSerial stm32f103 pin remapping

Posted: Mon Feb 06, 2017 9:08 am
by 41300895
Hello I want to use HardwareSerial with USART1 pin PB6, PB7 on stm32f103 blue pill board but I don't know how to define it in my code, please show me how

Re: HardwareSerial stm32f103 pin remapping

Posted: Mon Feb 06, 2017 10:50 am
by stevestrong
I would try:

Code: Select all

#include <libmaple/gpio.h>
...
afio_remap(AFIO_REMAP_USART1);

Re: HardwareSerial stm32f103 pin remapping

Posted: Mon Feb 06, 2017 11:01 pm
by stevestrong
And, did it work?

Re: HardwareSerial stm32f103 pin remapping

Posted: Mon Sep 11, 2017 1:52 am
by C_D
I just had to do the same thing but on USART3. The following worked for me:

Code: Select all

  // remap USART3
  afio_remap(AFIO_REMAP_USART3_PARTIAL);
  gpio_set_mode(GPIOC, 10, GPIO_AF_OUTPUT_PP);
  gpio_set_mode(GPIOC, 11, GPIO_INPUT_FLOATING);
  gpio_set_mode(GPIOC, 12, GPIO_AF_OUTPUT_PP);
If you do not explicitly set the gpio mode it does not work, I am guessing this is normally done somewhere in Serial3.begin() but that function wont know about the remapping.