cancel
Showing results for 
Search instead for 
Did you mean: 

Need Support regarding Drivers of STM32 F401 board.

Sarthakk_Sharma
Associate II

Hello Everyone,

I wrote the code by self for GPIO drivers , as a step by step process i am adding code for other peripherals & buses after taking due time in learning , the code progress as of now (as per my knowledge) should be enough to enable the GPIO peripherals & further toggling the internal LED at PA5 , but the LED is not toggling.
Any Solutions are invited. 
Below attached are the driver files of MCU.

File 1: STM32f401xx.h (stm32 F4 general drivers Header File)
File 2: STM32f401xx_gpio_driver.h (stm32 F4 GPIO drivers specific Header File)
File 3: STM32f401xx_gpio_drivers.c (stm32 F4 GPIO driver file).

/**********************The Code for Toggling Led ***********************/

#include <stdint.h>
#include "stm32F401xx.h"


void delay(uint32_t time_period)
{
    for(uint32_t i =0 ; i < time_period ; i++);
}
int main()
{
    GPIO_Handle_t GPIO_Internal_LED;

    GPIO_Internal_LED.pGPIOx = GPIOA;
    GPIO_Internal_LED.pGPIO_PinConfig_t->GPIO_PinNumber = GPIO_PIN_NO_5;
    GPIO_Internal_LED.pGPIO_PinConfig_t->GPIO_PinMode = GPIO_MODE_OUT;
    GPIO_Internal_LED.pGPIO_PinConfig_t->GPIO_PinSpeed = GPIO_SPEED_MEDIUM;
    GPIO_Internal_LED.pGPIO_PinConfig_t->GPIO_PinOPType = GPIO_OP_TYPE_PP;
    GPIO_Internal_LED.pGPIO_PinConfig_t->GPIO_PinPuPdControl = GPIO_NO_PU_PD;

    GPIO_PeriClkControl(GPIOA , ENABLE);
    GPIO_Init(&GPIO_Internal_LED);

    while(1)
    {
        GPIO_TogglePin(GPIOA,GPIO_PIN_NO_5);
        delay(1500);
    }
   
    return 0;
}

(All the functions are defined in "File 3").

Thanks !

12 REPLIES 12

@Pavel A.,

> what do you think is the "corresponding register": RCC register of the GPIO register?

I don't know, that's why I tried both.

Let's discuss this further in https://community.st.com/t5/stm32-mcu-products/erratum-quot-delay-after-an-rcc-peripheral-clock-enabling-quot/m-p/580035 as we've already hijacked this thread more than we should.

JW

so, could you pls. share a generic implementation how to ensure that?


Indeed I have a very simple and generic but functionally correct implementation for a few functions in plain C, which solve this issue and provide some other useful functionality. It looks like I have to write an article (with code) about it...