2024-03-19 05:53 AM - last edited on 2024-03-19 08:15 AM by Peter BENSCH
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
Solved! Go to Solution.
2024-03-19 09:40 AM - edited 2024-03-19 09:41 AM
@Tesla DeLorean wrote:Either you or a peripheral control the level.
@danielbathtub - you can see this in Figure 17 in the Reference Manual:
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:
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.
2024-03-19 08:36 AM
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
2024-03-19 08:43 AM
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
2024-03-19 09:40 AM - edited 2024-03-19 09:41 AM
@Tesla DeLorean wrote:Either you or a peripheral control the level.
@danielbathtub - you can see this in Figure 17 in the Reference Manual:
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:
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.