(solved)nucleo h743zi2 : help, serial port

All about boards manufactured by ST
Post Reply
jean-luc
Posts: 4
Joined: Wed Apr 07, 2021 9:21 pm

(solved)nucleo h743zi2 : help, serial port

Post by jean-luc »

Hello everybody,

I am trying to wirte a projet which use the serial1 of the nucleo h743zi2.
I am able to send data but no sucess to receive.

for this serial1, the variant.h gives the following

Code: Select all

  
  PB_7,  //D0 - USART_A_RX
  PB_6,  //D1 - USART_A_TX

but when I look at the PeripheralPin.C in the section for HAL_UART_MODULE I see that the line whith PB_7 is commented
Is it normal or is it an error in this file ? I yes, how is it possible to correct it ?

Thank you

Code: Select all

#ifdef HAL_UART_MODULE_ENABLED
WEAK const PinMap PinMap_UART_RX[] = {
  //  {PA_1,  UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // ETH RMII Ref Clk
  {PA_3,  USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
  //  {PA_8,  UART7,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, // USB SOF
  //  {PA_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB ID
  //  {PA_10, USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB ID
  //  {PA_11, UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, // USB DM
  {PB_3,  UART7,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, // SWO
  {PB_5,  UART5,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)},
  //  {PB_7,  LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, // LD2 LED_BLUE (ZI)
  //  {PB_7,  USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // LD2 LED_BLUE (ZI)
Last edited by jean-luc on Fri Apr 09, 2021 4:23 pm, edited 2 times in total.
User avatar
fpiSTM
Posts: 1022
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 47
Location: Le Mans
Contact:

Re: nucleo h743zi2 : help, serial port

Post by fpiSTM »

Hi @jean-luc
this is not an 'error', just it has been commented, probably because a LED is connected. anyway you can use it by redefining the PinMap_UART_RX array as it is a weak one.
simply copy it in your sketch and uncomment.
https://github.com/stm32duino/wiki/wiki ... nmap-array

With the next release all pins will be available.
jean-luc
Posts: 4
Joined: Wed Apr 07, 2021 9:21 pm

Re: nucleo h743zi2 : help, serial port

Post by jean-luc »

Very interesting answer, I will give a try.

Thanks a lot.
jean-luc
Posts: 4
Joined: Wed Apr 07, 2021 9:21 pm

Solved: nucleo h743zi2 : help, serial port

Post by jean-luc »

Good news, at the end I found the solution with this simple code :

Wondering why correct generic "PeripheralPins.c" is not provided ??????
At least, I learned something today but I could have avoid to spend hours searching for a solution !!! :evil:


Code: Select all

const PinMap PinMap_UART_TX[] = {
  {PB_6,  USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
  {PD_5,  USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
  {PD_8,  USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // STLink TX
  {NC,    NP,    0}
};

const PinMap PinMap_UART_RX[] = {
  {PB_7,  USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // LD2 LED_BLUE (ZI)
  {PD_6,  USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
  {PD_9,  USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // STLink RX
  {NC,    NP,    0}
};

HardwareSerial Serial1 (PB7,PB6);

void setup() {
  // initialize both serial ports:
  Serial.begin(115200);
  Serial1.begin(200000);
  Serial.write("bonjour");
}

void loop() {
  if (Serial.available()) {
    int inByte = Serial.read();
    Serial.write(inByte);
    Serial.write(" -\r\n");
    Serial1.write(inByte);
  }

  // read from port 0, send to port 1:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(" @ ");
    Serial.write(inByte);
    Serial.write(" +\r\n");
  }
}
Post Reply

Return to “STM boards (Discovery, Eval, Nucleo, ...)”