cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO_PinLockConfig() does not work

martindida
Associate II
Posted on October 29, 2012 at 08:54

I have a problem. I set my GPIO port pins on GPIOA. When I wanted to lock them I used GPIO_PinLockConfig function, but when the function passed through. It has done nothing. My pins in LCKR lock register was not locked? Why? I had set AHBPeriph clock because before I set GPIOA TypeDef register and it worked.          

Thanks.                               Martin.
4 REPLIES 4
Posted on October 29, 2012 at 14:59

This worked for me in Keil, returns 0x00010004, STM32F0-Discovery board

uint32_t testlock(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable the GPIO Clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
/* Configure the GPIO pin */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Lock the GPIO pin */
GPIO_PinLockConfig(GPIOA, GPIO_Pin_2);
return(GPIOA->LCKR);
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
martindida
Associate II
Posted on October 29, 2012 at 15:32

Thanks for your reply

Sequence of the code I wrote is the same as you wrote here. 1. I tried to debug it by hardware degugger ST LINK and I watched LCKR register of given PORT in system viewer windows. But nothing changed in LCKR register and as I mentioned I used the same sequence as you in your example. 2. When I tried to debug it by software KEIL simulator it everything worked well. All locked bits were set in and LCKK bit was set. I watched it in system viewer windows again. I am little bit afraid, that my MCU is little bit destroyd. At least LCKR register. I see it, that I will have to try it again. Even though thanks for your help.

martindida
Associate II
Posted on October 31, 2012 at 11:46

That one below does not work for me. Clive1 would you be able to help me?

0690X00000603FSQAY.jpg below is screenshot of LCKR register in system viewer windows from uVision studio by passing through GPIO_PinLockConfig function. As you can see tmp variable is correctly set, but LCKR is not changed when I pass function 0690X00000603FXQAY.jpg and last screenshot after passing function where you can see that LCKR is written to tmp variable and its value is zero. LCKR is not set. 0690X00000603FcQAI.jpg Thank for your help. Martin. From: clive1 Posted: Monday, October 29, 2012 2:59 PM Subject: GPIO_PinLockConfig() does not work

This worked for me in Keil, returns 0x00010004, STM32F0-Discovery board

uint32_t testlock(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable the GPIO Clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
/* Configure the GPIO pin */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Lock the GPIO pin */
GPIO_PinLockConfig(GPIOA, GPIO_Pin_2);
return(GPIOA->LCKR);
}

martindida
Associate II
Posted on October 31, 2012 at 11:50

Sorry it did not add printscreens. Why?