cancel
Showing results for 
Search instead for 
Did you mean: 

can all pins in stm32l-discovery be configured as gpio?

vicki19880929
Associate III
Posted on April 30, 2014 at 12:41

Hi all, 

I'm trying to do a simple toggling test with STM32L-discovery board and find that I'm not able to toggle some GPIO pins.  In my understanding, we could configure all the I/O pins to output mode.  For example, with the same code, I could toggle PB6 but not PC2...  Why is that?

int main(void)

{

    GPIO_InitTypeDef        GPIO_InitStructure;

    /* GPIOB Periph clock enable */

    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);

    /* Configure PD0 and PD1 or PD3 and PD7 in output pushpull mode */

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;

    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

    GPIO_Init(GPIOB, &GPIO_InitStructure);

    while(1) {

        GPIO_ToggleBits(GPIOC, GPIO_Pin_2);

        delay();

    }

    return 0;

}

1 REPLY 1
stm322399
Senior
Posted on April 30, 2014 at 14:06

Change first argument of GPIO_Init to GPIOC.

The discovery board has some reserved I/O (example 6 I/O reserved for touch sensing that are not easily accessible).