cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F412 GPIOx_LCKR->LCKy bits written although RM says they are not supposed to

DBabu.1
Associate

Hello,

I'm using STM32F412VG microcontroller and I'm evaluating GPIO locking feature. Here is a code snippet with my test:

  GPIO_InitTypeDef gpio;
 
  RCC_AHB1PeriphClockCmd(  RCC_AHB1Periph_GPIOD, ENABLE);
 
  GPIO_StructInit(&gpio);
  gpio.GPIO_Mode  = GPIO_Mode_OUT;
  gpio.GPIO_OType = GPIO_OType_PP;
  gpio.GPIO_Pin   = GPIO_Pin_13;
  gpio.GPIO_PuPd  = GPIO_PuPd_NOPULL;
  gpio.GPIO_Speed = GPIO_High_Speed;
 
  GPIO_Init(GPIOD, &gpio);
  GPIO_PinLockConfig(GPIOD, GPIO_Pin_13);
 
  GPIO_StructInit(&gpio);
  gpio.GPIO_Mode  = GPIO_Mode_OUT;
  gpio.GPIO_OType = GPIO_OType_PP;
  gpio.GPIO_Pin   = GPIO_Pin_12;
  gpio.GPIO_PuPd  = GPIO_PuPd_NOPULL;
  gpio.GPIO_Speed = GPIO_High_Speed;
 
  GPIO_Init(GPIOD, &gpio);
  GPIO_PinLockConfig(GPIOD, GPIO_Pin_12);

As you can see I've called GPIO_PinLockConfig function twice. It would mean that GPIOx_LCKR->LCKK Lock key bit for Port D is already active by first call at line 13. Because of the above and following entry in RM :

0693W000008GXzaQAG.png 

I've expected that second GPIO_PinLockConfig would not write LCK12 bit, because LCKK is already '1. However I can see in debugger that LCK12 was actually set. Could you please elaborate if I'm missing something or is RM inconsistent ? The Reference Manual, which I'm using is:

RM0402

Reference manual

STM32F412 advanced Arm®-based 32-bit MCUs

RM0402 Rev 6

0 REPLIES 0