2012-10-29 12:54 AM
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.2012-10-29 06:59 AM
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);
}
2012-10-29 07:32 AM
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.2012-10-31 03:46 AM
That one below does not work for me. Clive1 would you be able to help me?
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 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. Thank for your help. Martin. From: clive1 Posted: Monday, October 29, 2012 2:59 PM Subject: GPIO_PinLockConfig() does not workThis 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);
}
2012-10-31 03:50 AM
Sorry it did not add printscreens. Why?