2014-02-02 02:45 AM
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.2014-02-02 07:46 AM
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, Hal2014-02-02 08:05 AM
GPIO_Init(GPIOA, &GPIO_IS);
But not GPIOA right?2014-02-02 08:56 AM
Damnit, I'm totally blind sometimes. Thanks.