cancel
Showing results for 
Search instead for 
Did you mean: 

Handling 5V Logic Level Inputs on STM32F103RB (Hall Sensor & SPI MISO)

김형건
Associate

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!

1 ACCEPTED SOLUTION

Accepted Solutions
xisco
Associate III

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

View solution in original post

2 REPLIES 2
mƎALLEm
ST Employee

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:

mALLEm_0-1743329665691.png

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):

mALLEm_0-1743330862000.png

Hope that answers your question.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
xisco
Associate III

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