caizhiwei 发表于 2014-5-26 20:28:53

【STM32F429开发日志】1.MDK510工程建立和SYStick实现精确延时

 
收到429的开发板有一天时间了,这算是第一篇开发日志吧(昨天发的一篇不知道怎么没显示出来),希望对小伙伴们有用,以后我还会陆续推出其他的代码。
请看英文说明:
@par Example Description:

This example is used as a template project that can be used as reference to build
any new firmware application for STM32F429xx devices using the STM32F4xx Standard
Peripherals Library.
 
@par Hardware and Software environment


  - This example runs on STMF429xx Devices.
  - This example has been tested with STMicroelectronics STM32F429I-DISCO board 
    and can be easily tailored to any other supported device and development board.



硬件平台:stm32f429_discovery 
编译器:MDK 510
日期:2014.5.25


1.该例程在官方的驱动下完善,修改stm32f429i_discovery.c 文件较多,简化了LED和Key的驱动;
2.使用的外部8Mhz晶振,主频为180Mhz。
3.实现功能:利用systick定时器使2个LED间隔500ms轮流闪烁。


主要代码:
#include "SysTick.h"


__IO uint32_t TimingDelay;


/******************************************************************************************
*函数名称:void SysTick_Init(void)
*
*入口参数:无
*
*出口参数:无
*
*功能说明:SysTick初始化  如果初始化失败,会停入WHILE死循环
*******************************************************************************************/
void SysTick_Init(void)
{
    if (SysTick_Config(SystemCoreClock / 1000))  //SysTick end of count event each 1ms 
    { 
        while (1); //初始化失败
    }
}


/******************************************************************************************
*函数名称:void Delay(__IO uint32_t nTime)
*
*入口参数:无
*
*出口参数:无
*
*功能说明:供外部调用的延时函数
*******************************************************************************************/
void Delay(__IO uint32_t nTime)

    TimingDelay = nTime;
    
    while(TimingDelay != 0);
}


/******************************************************************************************
*函数名称:void TimingDelay_Decrement(void)
*
*入口参数:无
*
*出口参数:无
*
*功能说明:SysTick中断调用函数
*******************************************************************************************/
void TimingDelay_Decrement(void)
{
    if (TimingDelay != 0x00)
    { 
        TimingDelay--;
    }
}


/**
  * @brief  This function handles SysTick Handler.
  * @param  None
  * @retval None
  */


void SysTick_Handler(void)
{
  TimingDelay_Decrement();
}


 
工程下载:
 

johnzyp 发表于 2015-3-4 21:52:50

写的非常好。
页: [1]
查看完整版本: 【STM32F429开发日志】1.MDK510工程建立和SYStick实现精确延时