cancel
Showing results for 
Search instead for 
Did you mean: 

set voltage for GPIO PINS

musthafafarhan
Associate II
Posted on January 13, 2016 at 04:54

May I ask few doubts?

Hi  all, I have already gone through lot of studies regarding to GPIO configuration, TIM initialization and, to generate Pulse signal from one of I/O pins of stm32f4. Now I know the way to set the frequency and other necessary configuration except voltage level.

when I wanted to learn that I need to set the specific voltage for the specific pins.

for instance,

If I have selected Pin (PD12 it is located at TIM4, Channel 1) � I need set 5V output

and,

If I have selected another Pin (PD13 it is located at TIM4, Channel 2) � here I need to set 3.3V output.

what is the way to set the specific voltage for certain pins ?

Thanks for your time. your comments would be greatly appreciated.

#stm32-stm32f4-stm32f407-gpio-pwm
3 REPLIES 3
re.wolff9
Senior
Posted on January 13, 2016 at 08:43

You're not saying what CPU you're using exactly, but  in general: 

Alas, this is not possible as far as I know. 

Some input pins allow you to drive them with 5V, but others only 3.3V. 

The last few STM chips that have come out will have a separate bank of IOs that can use a different IO voltage. But as far as I know, it is not allowed to use more than 3.3V nominal (3.6Vmax). 

That said: many (modern) 5V chips will correctly detect a 3.3V signal as high without any level shifter or something like that. Not ideal, but it works. Depending on what your project is, it might be acceptable to do it that way. If you go that way, make sure that your 5V is not too high. The margins get less when the 5V supply is higher than 5V. 

pkumar1883
Associate II
Posted on January 13, 2016 at 11:53

Dear Farhan.musthafa,

It doesnt look possible. You only can configure a GPIO either SET(high level) or RESET(low level). But if you want to generate desired analog output you should use DAC channels.

Posted on January 13, 2016 at 12:22

You could program the pins in OD (Open Drain) mode, and pull-up the respective pins to 5V and 3.3V externally with a resistor. Depending on the frequency and loading, this would get you pretty close to what you want.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..