|
/************************************
标题:定时器TIM7的定时练习
软件平台:IAR for ARM6.21
硬件平台:stm32f4-discovery
主频:168M
author:小船
data:2012-02-06
*************************************/
#include <stm32f4xx.h>
#include "MyDebugger.h"
void main ()
{
SCB->AIRCR = 0x05AF0000 | 0x400; //中断优先级分组 抢占:响应=3:1
RCC->APB1ENR |= (1<<5); //打开TIM7时钟
TIM7->PSC = 8399; //对时钟84M进行8400分频,使得计数频率为10k
TIM7->ARR = 10000; //定时一秒
TIM7->CNT = 0; //清空计数器
TIM7->CR1 |= (1<<7); //自动重装载预装载使能
TIM7->DIER |= 1; //使能中断
NVIC->IP[55] = 0x80;
NVIC->ISER[1] |= (1<<(55-32));
TIM7->CR1 |= 1; //开始计时
MyDebugger_Init();
while(1)
{
};
}
void TIM7_IRQHandler(void)
{
if(TIM7->SR)
{
MyDebugger_LEDs(blue, turn);
TIM7->SR &= ~(0x0001);
}
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|