Author Topic: Purpose of locking GPIO on STM32F4s  (Read 1990 times)

0 Members and 1 Guest are viewing this topic.

Offline BurnedResistorTopic starter

  • Regular Contributor
  • *
  • Posts: 192
  • Country: at
Purpose of locking GPIO on STM32F4s
« on: October 31, 2016, 06:42:14 pm »
While skimming over the reference manual for the STM32F4, I noticed that it feature a gpio lock. Single pins can be locked until a full reset of the mcu. What is the practical purpose of this feature?
 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: Purpose of locking GPIO on STM32F4s
« Reply #1 on: November 01, 2016, 03:28:29 am »
Those pins might be connected to something that could do Bad Things if fiddled with at the wrong time. It's a safety feature which limits the effect of software bugs and hardware glitches, hopefully preventing the device from damaging equipment or killing people when it misoperates.

To be clear - the lock function works on the port's configuration bits, not the output data or set/reset registers. So locking a pin doesn't prevent it from being used, but does prevent it from being changed from one configuration/mode to another. So for example if a pin is set to be a push-pull output, after locking the configuration it can't accidentally be set to eg. analog input mode.

This feature makes sense because usually once a GPIO port pin has been set up (to match the external hardware) it won't be changed again (until Reset, when all pins are set back to floating input mode).


   
 
The following users thanked this post: BurnedResistor

Offline BurnedResistorTopic starter

  • Regular Contributor
  • *
  • Posts: 192
  • Country: at
Re: Purpose of locking GPIO on STM32F4s
« Reply #2 on: November 01, 2016, 10:28:56 am »
Aha that makes sense!

Thank you!
 

Offline jnz

  • Frequent Contributor
  • **
  • Posts: 593
Re: Purpose of locking GPIO on STM32F4s
« Reply #3 on: November 02, 2016, 05:42:07 pm »
FWIW... Practical example, airbag driver or other explosive elements.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf