Skip to main content
Steven Yen
Associate
July 14, 2017
Solved

STM32 F3 Discovery with GPIO E configure issue

  • July 14, 2017
  • 3 replies
  • 1193 views
Posted on July 14, 2017 at 07:58

I just bought STM32 MCU Discovery Kits and want to set PE3, PE4, PE5, PE8 as GPIO output.

I made the codes via STM32CubeMX and downloaded it to the board successfully.

But I found PE4 adn PE5 configure fail, while PE3 and PE8 work well.

Hope anyone can help me, thanks in advance.

The codes is shown below:

int main(void)

{

HAL_Init();

SystemClock_Config();

MX_GPIO_Init();

while (1)

{

HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_8);

HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_3);

HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_4);

HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_5);

HAL_Delay(1000);

}

}

void SystemClock_Config(void)

{

RCC_OscInitTypeDef RCC_OscInitStruct;

RCC_ClkInitTypeDef RCC_ClkInitStruct;

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;

RCC_OscInitStruct.HSIState = RCC_HSI_ON;

RCC_OscInitStruct.HSICalibrationValue = 16;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

Error_Handler();

}

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)

{

Error_Handler();

}

HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

}

void MX_GPIO_Init(void)

{

GPIO_InitTypeDef GPIO_InitStruct;

__HAL_RCC_GPIOE_CLK_ENABLE();

HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5 | GPIO_PIN_8, GPIO_PIN_RESET);

GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

}

    This topic has been closed for replies.
    Best answer by Tilen MAJERLE
    Posted on July 14, 2017 at 11:31

    Hello

    icegod0803

    ‌,

    with this board configuration, you cannot or your devicecan be broken because of short circuit.

    You can use all others which are free or are not connected directly to other output pin.

    3 replies

    Tilen MAJERLE
    ST Employee
    July 14, 2017
    Posted on July 14, 2017 at 10:12

    Hello

    icegod0803

    ‌,

    I don't know what approach you did to find that it does not work, but if you check the schematics for your board, you will see that on pins that don't work you have connected some peripherals.

    From downloaded file, I assume you have F303-Discovery, so I'm sending you the website with schematics download.

    http://www.st.com/en/evaluation-tools/stm32f3discovery.html

    If I'm more specific, PE4 and PE5 pins are connected to outputs ofLSM303DLHC device. Device's pins are IRQ outputs and this means you have 2 outputs connected together which can cause short circuit.

    Steven Yen
    Associate
    July 14, 2017
    Posted on July 14, 2017 at 11:04

    This means I can't configure PE4 and PE5 as GPIO output if use 

    F303-Discovery, right?

    Tilen MAJERLE
    Tilen MAJERLEBest answer
    ST Employee
    July 14, 2017
    Posted on July 14, 2017 at 11:31

    Hello

    icegod0803

    ‌,

    with this board configuration, you cannot or your devicecan be broken because of short circuit.

    You can use all others which are free or are not connected directly to other output pin.