//*********************************************************************************************** // Hardwarebasis: F4DISCOVERY // Programm: Blinky // Mikrocontroller: STM32F407VG (ARM 32-bit CORTEX-M4) // Speicher: 1MB FLASH, 192KB SRAM // Taktfrequenz: Quarz: 8MHz, mit PLL auf: 168MHz // Stand: 16.12.2012 // IDE/Compiler: CooCox CoIDE 1.5.1 //*********************************************************************************************** /* Hinweis zum Clock fuer 8MHz Quarz, damit er auf 168MHz läuft (betrifft das stm32F4Discovery): in der system_stm32f4xx.c muss eingetragen sein: PLL_M = 8 in der stm32f4xx.h muss eingetragen sein: HSE_VALUE = 8000000 */ // Includes #include #include #include "stm32f4xx.h" #include "stm32f4xx_gpio.h" #include "stm32f4xx_rcc.h" // Defines // LEDs #define LD_3_AUS GPIO_ResetBits(GPIOD,GPIO_Pin_13) // orange LED #define LD_3_EIN GPIO_SetBits(GPIOD,GPIO_Pin_13) static uint32_t TimingDelay; // Peripherie-Einstellungen void SetupPeripherie(void) { GPIO_InitTypeDef GPIO_InitStructure; // GPIOD Takt freigeben RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); // LEDs als Ausgang GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_Init(GPIOD, &GPIO_InitStructure); } void Delay(uint32_t nTime) { TimingDelay = nTime; while (TimingDelay != 0) ; } void TimingDelay_Decrement(void) { if (TimingDelay != 0x00) { TimingDelay--; } } void SysTick_Handler(void) { TimingDelay_Decrement(); } int main(void) { SystemInit(); SetupPeripherie(); if (SysTick_Config(SystemCoreClock / 1000)) { /* Capture error */ while (1) ; } while (1) { LD_3_EIN; Delay(1000); //1000ms Delay LD_3_AUS; Delay(1000); //1000ms Delay } }