AnsweredAssumed Answered

Strange problem with configuring output pins

Question asked by kureigu on Feb 2, 2014
Latest reply on Feb 2, 2014 by kureigu
I'm using the below code to activate output pins. 

01.void GPIO_cfg(void){
02.     
03.    GPIO_InitTypeDef GPIO_IS;       // GPIO Initialisation Structure => GPIO_IS
04. 
05.         // Configure/enable peripheral clocks
06.    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
07.  
08.    GPIOB->MODER   =   (0x00001000);    // This line works
09. 
10.    /* Configure PE15 in output pushpull mode */
11.     GPIO_IS.GPIO_Pin = GPIO_Pin_6;           // Configure pin 6 
12.    GPIO_IS.GPIO_Mode = GPIO_Mode_OUT; // These lines don't work
13.    GPIO_IS.GPIO_OType = GPIO_OType_PP;
14.    GPIO_IS.GPIO_Speed = GPIO_Speed_2MHz;
15.    GPIO_IS.GPIO_PuPd = GPIO_PuPd_NOPULL;
16.    GPIO_Init(GPIOA, &GPIO_IS);
17.         
18.    GPIO_SetBits(GPIOB, GPIO_Pin_6);
19.     
20.}

If I remove the "GPIOB->MODER" section, it no longer correctly configures the output, not a clue why. Seems like maybe there's a problem with the GPIO_Init() function?

I'm using an STM32L152 Discovery board.

Outcomes