CortexM0菜鸟之节拍中断(第8天作业)

2010年09月07日 00:28    发布者:hotpower
由于前几天事太多,近日继续M0菜鸟的历程。以下是systick.cpp文件源码

#include "systick.h"
extern "C" void __irq SysTick_Handler(void)
{
static int count = 0;
if (count++ >= 50)//500mS
{
  PortLed8.DATA.Bits.PinLed8 ^= 1;//LED8每半秒闪烁一次
  count = 0;
}
}
SysTickObj::SysTickObj (void)
{
    SysTickInit();//节拍定时器初始化
}
void SysTickObj::SysTickInit(void)
{
//位域写法
SYSTick.STCTRL.Bits.ENABLE = 1;//系统节拍计数器使能
SYSTick.STCTRL.Bits.TICKINT = 1;//系统节拍中断使能
//寄存器写法
// SYSTick.STCTRL.Regs = (1 << SYSTick_ENABLE)//系统节拍计数器使能  
//                     | (1 << SYSTick_TICKINT);//系统节拍中断使能
SYSTick.STRELOAD.Regs = (SystemFrequency / 1000 * 10) - 1;//10mS节拍中断
}


HotPower@163.com  2010.9.6 23:38 于雁塔菜地

菜农通讯工具:

新浪网页版:http://t.sina.com.cn/hotpower
新浪手机版:http://t.sina.cn/hotpower

网 易微 博:http://t.163.com/hotpower
腾讯QQ:    1270688699

菜农邮箱:     HotPower@163.com
菜农导航: http://www.hotpage.net.cn/

http://www.hotpage.net.cn/hotpagelogo.gifhttp://www.eechina.com/images/logo.gifhttp://www.hotpage.net.cn/hotpowerlogo.gifhttp://www.eefocus.com/images/dictionary/dict/logo.gif