2025-03-30 2:57 AM
Hi everyone,
I'm currently working on a BLDC motor control project using the STM32F103RB (Nucleo-F103RB) board. I have two questions regarding handling 5V logic signals with this MCU:
I need to read 5V logic-level signals from a BLDC motor's Hall sensors. As far as I understand, most GPIOs on the STM32F103RB are designed for 3.3V logic. However, I read that some GPIOs are 5V-tolerant.
→ How can I configure GPIO pins in STM32CubeIDE to safely accept 5V logic inputs from the Hall sensors? Is there any specific setting in the GPIO configuration in CubeMX/IDE, or are the 5V-tolerant pins automatically handled by the hardware?
I'm also using SPI to communicate with a motor driver IC. In this setup:
STM32 sends 3.3V logic signals via MOSI.
The motor driver IC responds with 5V logic levels on MISO.
→ Is it safe to connect the 5V MISO signal directly to the STM32F103RB? Can STM32 SPI peripherals accept 5V logic levels on the MISO line without damage? If yes, do I need to configure anything specific for this?
Any clarification or recommendations would be greatly appreciated.
Thanks in advance!
Solved! Go to Solution.
2025-03-30 3:31 AM
Hello,
Looking at datasheet, the following pins,
PA4/SPI1_NSS is NOT five volts tolerant
PA5/SPI1_SCK is NOT five volts tolerant
PA6/SPI1_MISO is NOT five volts tolerant
PA7/SPI1_MOSI is NOT five volts tolerant
PB13/SPI2_SCK is five volts tolerant
PB14/SPI2_MISO is five volts tolerant
PB15/SPI2_MOSI is five volts tolerant
Looking it, SPI1 is NOT five volts tolerant, and SPI2 is five volts tolerant.
You need to use SPI2. No need any configuration. Its configured internally by hardware.
Regards
2025-03-30 3:17 AM - edited 2025-03-30 3:35 AM
Hello,
The five volt tolerent is managed by hardware on the IO structture itself. Nothing to do in the software:
The FT in this table in the datasheets tells what are the IOs five volt tolerent:
If an IO is FT means the alternate function available on the that IO supports the 5V input.
Also you need to take care about the sink current (five volt tolerent or not):
Hope that answers your question.
2025-03-30 3:31 AM
Hello,
Looking at datasheet, the following pins,
PA4/SPI1_NSS is NOT five volts tolerant
PA5/SPI1_SCK is NOT five volts tolerant
PA6/SPI1_MISO is NOT five volts tolerant
PA7/SPI1_MOSI is NOT five volts tolerant
PB13/SPI2_SCK is five volts tolerant
PB14/SPI2_MISO is five volts tolerant
PB15/SPI2_MOSI is five volts tolerant
Looking it, SPI1 is NOT five volts tolerant, and SPI2 is five volts tolerant.
You need to use SPI2. No need any configuration. Its configured internally by hardware.
Regards