serial UART1

Post Reply
lejibxl
Posts: 2
Joined: Fri Mar 11, 2022 12:44 pm

serial UART1

Post by lejibxl »

on a G041F8Px I can't use the UART1 (PB7, PB3)
Even if I initialize the port with

Code: Select all

HardwareSerial Serial1(PB7,PB3); // RX, TX
I can't send or receive.
What is strange is that the TX (PB3) is at idle low (and not high)??
Anyone have any idea, am I doing something wrong?
lejibxl
Posts: 2
Joined: Fri Mar 11, 2022 12:44 pm

Re: serial UART1

Post by lejibxl »

you must use PB6 instead of PB3 in the initialization! Yet the first in MX, we speak first of PB3??
Attachments
2022-03-11_14-01-07.jpg
2022-03-11_14-01-07.jpg (5.26 KiB) Viewed 6551 times
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: serial UART1

Post by fpiSTM »

Here is the available pins vs U(S)ART instance available for G041F

Code: Select all

#ifdef HAL_UART_MODULE_ENABLED
WEAK const PinMap PinMap_UART_TX[] = {
  {PA_2,      LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)},
  {PA_2_ALT1, USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)},
  {PA_9_R,    USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)},
  {PA_14,     USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)},
  {PB_6,      USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)},
  {NC,        NP,      0}
};
#endif

#ifdef HAL_UART_MODULE_ENABLED
WEAK const PinMap PinMap_UART_RX[] = {
  {PA_3,      LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)},
  {PA_3_ALT1, USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)},
  {PA_10_R,   USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)},
  {PA_15,     USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)},
  {PB_7,      USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)},
  {NC,        NP,      0}
};
So PB7 is linked to USART1 and PB3 has no U(S)ART. As you stated use PB6.
Post Reply

Return to “STM32G0 based boards”