1

I just started programming the Nucleo-F446RE (Based on the STM32F446RE MCU).

I can't seem to get a pin to go active, I'm trying to just toggle a GPIO using the following code:

//*****************************************************************************
#include "stm32f446xx.h"
#include "stm32f4xx_hal.h"
//! \file main.c
//! \brief main application
//! \version 1.0.0.0
//! \date $Creat_time$
//! \author $Creat_author$
//! \copy
//!
//! Copyright (c) 2014 CooCox.  All rights reserved.
//
//! \addtogroup project
//! @{
//! \addtogroup main
//! @{
//*****************************************************************************

int main(void)

__HAL_RCC_GPIOA_CLK_ENABLE();
     GPIO_InitTypeDef GPIO_InitTypeDefStruct;

     GPIO_InitTypeDefStruct.Pin = GPIO_PIN_1;
     GPIO_InitTypeDefStruct.Speed = GPIO_SPEED_LOW;
     GPIO_InitTypeDefStruct.Pull = GPIO_PULLUP;
     GPIO_InitTypeDefStruct.Mode = GPIO_MODE_OUTPUT_PP;

    HAL_GPIO_Init(GPIOA, &GPIO_InitTypeDefStruct);


    while(1)

    {
        HAL_GPIO_TogglePin(&GPIO_InitTypeDefStruct,GPIO_PIN_1);


    }

It doesn't seem to work though..I've gone through the header file and c file of the GPIO which explains how to go about setting the pin, although even following this to the bone, it just stays low. Where am I going wrong?

Thanks in advance for any help

4

1 回答 1

0


HAL_GPIO_TogglePin(&GPIO_InitTypeDefStruct,GPIO_PIN_1);

本来应该

HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_1);
于 2017-07-07T17:09:52.027 回答