Page 1 of 1

ModBUS and PN532 libraries via hardware serial ports on STM32F446RET6

Posted: Wed Mar 12, 2025 8:21 am
by juan
I've been programming my projects with Atmel and ESP8266/ESP32 for a while now. I've purchased a WeAct Studio module with an STM32F446RET6. I use Visual Studio Code with PlatformIO and the Arduino framework for programming. I've tried all the UART/USARTs and I've been able to read the signals on the serial monitor using a TTL-USB converter.
However, if I use the emelianov's ModBUS library v4.1.1 or the Seeed-Studio PN532 library through the serial ports, both don't work. When I connect the TTL-ModBUS RTU converter, I get no response. When I connect the PN532 NFC module, it detects it, reads the firmware version, but doesn't go past line 182 of the PN532.cpp file:

Code: Select all

if (HAL(writeCommand)(pn532_packetbuffer, 3)) {
  return 0x0;  // command failed
}
Is the same thing happening to you?

Re: ModBUS and PN532 libraries via hardware serial ports on STM32F446RET6

Posted: Sat Apr 26, 2025 3:18 am
by Ricardowell
juan wrote: Wed Mar 12, 2025 8:21 am I've been programming my projects with Atmel and ESP8266/ESP32 for a while now. I've purchased a WeAct Studio module with an STM32F446RET6. I use Visual Studio Code with PlatformIO and the Arduino framework for programming. I've tried all the UART/USARTs and I've been able to read the signals on the serial monitor using a TTL-USB converter.
However, if I use the Monkey Mart emelianov's ModBUS library v4.1.1 or the Seeed-Studio PN532 library through the serial ports, both don't work. When I connect the TTL-ModBUS RTU converter, I get no response. When I connect the PN532 NFC module, it detects it, reads the firmware version, but doesn't go past line 182 of the PN532.cpp file:

Code: Select all

if (HAL(writeCommand)(pn532_packetbuffer, 3)) {
  return 0x0;  // command failed
}
Is the same thing happening to you?
Yeah, I had a similar issue with STM32 and serial libs not playing nice. It turned out to be a timing/baud rate mismatch and also needing proper pin remapping with SerialX.setRx/Tx(). Might be worth double-checking those and making sure the UART you're using isn't reserved for debug.