cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0x series multiple GPIO Pin functions

danielbathtub
Associate III

Hi, 

Can I control the level of a GPIO Pin in software, if the GPIO Pin is in an Alternative function mode ? 

For example, I have an application where I switch a MOSFET in Software, but I would like to use the Hardware or internal Silicon, and Software to turn the Pin on and Off, is this possible with the STM32G031 controllers ?. 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions

@Tesla DeLorean wrote:

Either you or a peripheral control the level.


@danielbathtub - you can see this in Figure 17  in the Reference Manual:

AndrewNeil_0-1710866171327.png

The multiplexer connects either the Output Data Register (ODR) or the Alternate Function (AF) to the output driver.

Figure 20 shows the case when the output is configured as AF:

AndrewNeil_1-1710866339027.png

Note that the ODR is disconnected from the output driver - only the AF is connected.

So your software writing to the ODR in this case will have no effect.

 

View solution in original post

3 REPLIES 3
Peter BENSCH
ST Employee

I haven't quite understood exactly what you want to achieve, but GPIOs can of course be switched on or off. If a MOSFET is to be switched, for example to generate a PWM, then a timer peripheral can also do this in hardware.

Does this answer your question?

Regards
/Peter

In order 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.

Either you or a peripheral control the level. If you need to take control, remove it from the peripheral (AF)

If you want to drive a pattern against a port bank, you can DMA into GPIO->BSRR

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

@Tesla DeLorean wrote:

Either you or a peripheral control the level.


@danielbathtub - you can see this in Figure 17  in the Reference Manual:

AndrewNeil_0-1710866171327.png

The multiplexer connects either the Output Data Register (ODR) or the Alternate Function (AF) to the output driver.

Figure 20 shows the case when the output is configured as AF:

AndrewNeil_1-1710866339027.png

Note that the ODR is disconnected from the output driver - only the AF is connected.

So your software writing to the ODR in this case will have no effect.