Hi everyone,
I want to turn on a LED on my STM32F4-discovery board using atollic truestudio
Followed following step's to create the project
File -> New -> C Project
Project Name : LEDTOGGLE
EMBEDDEC C PROJECT
Next
Target -> STM32F4-> Boards->STM32F4_Discovery
Next
Next
Finish
generated code after a finish
Here is mine code :
It compiles successfully but LED doesn't turn ON. I don't know what is wrong with this.
Can you help me ?
I want to turn on a LED on my STM32F4-discovery board using atollic truestudio
Followed following step's to create the project
File -> New -> C Project
Project Name : LEDTOGGLE
EMBEDDEC C PROJECT
Next
Target -> STM32F4-> Boards->STM32F4_Discovery
Next
Next
Finish
generated code after a finish
Code:
/* Includes */
#include "stm32f4xx.h"
#include "stm32f4_discovery.h"
/* Private macro */
/* Private variables */
/* Private function prototypes */
/* Private functions */
/**
**===========================================================================
**
** Abstract: main program
**
**===========================================================================
*/
int main(void)
{
int i = 0;
/**
* IMPORTANT NOTE!
* The symbol VECT_TAB_SRAM needs to be defined when building the project
* if code has been located to RAM and interrupts are used.
* Otherwise the interrupt table located in flash will be used.
* See also the <system_*.c> file and how the SystemInit() function updates
* SCB->VTOR register.
* E.g. SCB->VTOR = 0x20000000;
*/
/* TODO - Add your application code here */
/* Initialize LEDs */
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
STM_EVAL_LEDInit(LED5);
STM_EVAL_LEDInit(LED6);
/* Turn on LEDs */
STM_EVAL_LEDOn(LED3);
STM_EVAL_LEDOn(LED4);
STM_EVAL_LEDOn(LED5);
STM_EVAL_LEDOn(LED6);
/* Infinite loop */
while (1)
{
i++;
}
}
/*
* 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;
}
Code:
/* Includes */
#include "stm32f4xx.h"
#include "stm32f4_discovery.h"
GPIO_InitTypeDef GPIO_InitStructure;
#define DELAY 1000000
void delay( unsigned long d)
{
while(--d);
}
int main(void)
{
/* GPIOD Periph clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
/* Configure PD12 in output pushpull mode */
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)
{
GPIO_SetBits(GPIOD, GPIO_Pin_12);
delay(DELAY);
GPIO_ResetBits(GPIOD, GPIO_Pin_12);
delay(DELAY);
}
}
/*
* 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;
}
Can you help me ?
