AnsweredAssumed Answered

GPIO with stm32l0 discovery

Question asked by nashimoto on Nov 2, 2015
Latest reply on Nov 3, 2015 by nashimoto
Hi everyone,

I'm a newbie of embedded programming and this is my first post.

I have a STM32L0 Discovery board and wanted to supply electricity to an external circuit.
The external circuit has only a LED and a resistor.
I referred to official samples (stm32cubel0 and stm32snippetsl0) and tried it.
But it didn't work.

This is my partial code.
void Configure_GPIO(void)
{
  RCC->IOPENR |= RCC_IOPENR_GPIOAEN;
 
  GPIO_InitTypeDef GPIO_InitStructure;
  GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6;
  GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStructure.Pull   = GPIO_NOPULL;
  GPIO_InitStructure.Speed  = GPIO_SPEED_HIGH;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
}
 
void main(void)
{
  // ---- initialization ----
  ...
  ...
  Configure_GPIO();
 
  // my operations: make an external LED blink
  while(1) /* Infinite loop */
  {
    volatile int i=0;
     
    // PA1-4, 6: turn on
    GPIOA->BSRR = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6;
    for (i=0;i<900000;i++);  // wait
    // PA1-4, 6: turn off
    GPIOA->BRR = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6;
    for (i=0;i<1800000;i++); // wait
  
}

I connected PA1 (or PA2, 3,...) and GND line to the external circuit.

I found that only PA4 could supply electricity and made the LED blink, but others could not do in spite of the same configuration.
Also, I checked the flag status of GPIO (such as GPIOA->MODE) and PA1-4, 6 were same configuration except IDR and ODR.

What should I do next?
Would you help me?

Outcomes