How to turn on the LED on STM32F4 Discovery Board

MrChips

Joined Oct 2, 2009
35,299
I don't know from where you are copying your codes.
Open the file called stm32f4xx_gpio.h to find out what are the correct labels.

Here is the corrected code:
C:
/* Infinite loop */
         while (1)
         {
            if (GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_0))
                 {
                        GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_RESET);
                 }
             else
                 {
                         GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_SET);
                 }
         }
 

Thread Starter

skyr6546

Joined Mar 22, 2019
73
I don't know from where you are copying your codes.
Open the file called stm32f4xx_gpio.h to find out what are the correct labels.

Here is the corrected code:
C:
/* Infinite loop */
         while (1)
         {
            if (GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_0))
                 {
                        GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_RESET);
                 }
             else
                 {
                         GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_SET);
                 }
         }
What's is meaning of this error ?

..\src\system_stm32f4xx.c: In function 'SetSysClock':
..\src\system_stm32f4xx.c:399:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL);
^~~~~
..\src\system_stm32f4xx.c:400:5: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'while'
{
^
C:
/* Includes */
#include "stm32f4xx.h"
#include "stm32f4_discovery.h"


int main(void)
{

    /* GPIOD Periph clock enable */
          RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

          GPIO_InitTypeDef  GPIO_InitStructure;


          /* Configure pin_A0 as input */
         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
         GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
         GPIO_Init(GPIOD, &GPIO_InitStructure);

          /* Configure PD12 in output */
          GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
          GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
          GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
          GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
          GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
          GPIO_Init(GPIOD, &GPIO_InitStructure);
          /* Infinite loop */
                   while (1)
                   {
                      if (GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_0))
                           {
                                  GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_RESET);
                           }
                       else
                           {
                                   GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_SET);
                           }
                   }
}


/*
* Callback used by stm32f4_discovery_audio_codec.c.
* Refer to stm32f4_discovery_audio_codec.h for more info.
*/
void EVAL_AUDIO_TransferComplete_CallBack(uint32_t pBuffer, uint32_t Size){
  /* TODO, implement your code here */
  return;
}

/*
* Callback used by stm324xg_eval_audio_codec.c.
* Refer to stm324xg_eval_audio_codec.h for more info.
*/
uint16_t EVAL_AUDIO_GetSampleCallBack(void){
  /* TODO, implement your code here */
  return -1;
}
 
Top