cancel
Showing results for 
Search instead for 
Did you mean: 

LCKR register useage

suhel
Associate

Hi ,

I am using the stm32f411VET MC board, now i implemented the code to check how LCKR

register work. This is the code which i implemented for that, but when i debugged it

the LCKR register bits has not set. Any one can help me.

 

/*

* interfacing LED with PD12

*/

 

 

 

#include <stdio.h>

#include<stdint.h>

// step - 1 : pointer variable for RCC_AHB1ENR

 

unsigned long int *pRCC_AHB1ENR = (unsigned long int*) 0x40023830;

 

// step - 2 : pointer variable for MODER

 

unsigned long int *pGPIOD_MODER = (unsigned long int*) 0x40020C00;

 

// step - 3 : pointer variable for ODR

 

unsigned long int *pGPIOD_ODR = (unsigned long int*) 0x40020C14;

 

unsigned long int *pGPIOD_LCKR = (unsigned long int*) 0x40020C1C;

 

int main()

// SHORT HAND

 

{

// enabling the clock of GPIOD peripheral

*pRCC_AHB1ENR |= (1<<3);

 

// making the pin 12 as out put mode

 

// set the 24th bit

*pGPIOD_MODER |= (1<<24);

 

// clear the 25th bit

 

*pGPIOD_MODER &= ~(1<<25);

 

*pGPIOD_LCKR |= (1 << 12);

*pGPIOD_LCKR |= (1 << 16);

*pGPIOD_LCKR &= ~(1 << 16);

*pGPIOD_LCKR |= (1 << 16);

uint32_t tmp = *pGPIOD_LCKR;

tmp = *pGPIOD_LCKR;

 

// set the 24th bit

*pGPIOD_MODER &= ~(1<<24);

 

// clear the 25th bit

*pGPIOD_MODER &= ~(1<<25);

// making pin high using ODR

 

*pGPIOD_ODR |= (1<<12);

 

return 0;

}

 

0 REPLIES 0