Strange problem with configuring output pins
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-02 2:45 AM
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.
This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-02 7:46 AM
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, HalOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-02 8:05 AM
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..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-02 8:56 AM
Posted on February 02, 2014 at 17:56
Damnit, I'm totally blind sometimes. Thanks.
