cancel
Showing results for 
Search instead for 
Did you mean: 

Strange problem with configuring output pins

craig239955_stm1_st
Associate II
Posted on February 02, 2014 at 11:45

I'm using the below code to activate output pins.


void
GPIO_cfg(
void
){


GPIO_InitTypeDef GPIO_IS; 
// GPIO Initialisation Structure => GPIO_IS


// Configure/enable peripheral clocks

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);


GPIOB->MODER = (0x00001000); 
// This line works


/* Configure PE15 in output pushpull mode */

GPIO_IS.GPIO_Pin = GPIO_Pin_6; 
// Configure pin 6

GPIO_IS.GPIO_Mode = GPIO_Mode_OUT;

// These lines don't work


GPIO_IS.GPIO_OType = GPIO_OType_PP;

GPIO_IS.GPIO_Speed = GPIO_Speed_2MHz;

GPIO_IS.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_Init(GPIOA, &GPIO_IS);


GPIO_SetBits(GPIOB, GPIO_Pin_6);


}

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.
3 REPLIES 3
raptorhal2
Lead
Posted on February 02, 2014 at 16:46

You don't show definitions for the members of GPIO_IS structure. My guess is that they are missing or incorrect.

Use the GPIO_InitStructure provided by the Library, and all should go well.

Cheers, Hal

Posted on February 02, 2014 at 17:05

GPIO_Init(GPIOA, &GPIO_IS);

But not GPIOA right?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
craig239955_stm1_st
Associate II
Posted on February 02, 2014 at 17:56

Damnit, I'm totally blind sometimes. Thanks.