#include "SmartM_M0.h"
unsigned char i;
VOID TMR1Init(VOID)
{
PROTECT_REG
(
APBCLK |= 0x08; //定时器1时钟使能
CLKSEL1 |= 0x4000; //定时器1时钟选择外部高速晶振0X000,内部22为0X4000
IPRSTC2 |= 0x40; //TIMER1先复位
IPRSTC2 &= 0xFB; //定时器1正常工作
TCSR1 &= 0x18FFFF00;//先清0
TCSR1 |= 0x6C000000; //赋值:计数开始、使能定时器中断、周期模式、重置预分频值、
TCMPR1 = 12000*50; //设置比较值 [0~16777215]
NVIC_ISER |= 0x0200; //TMR0_INT;
)
}
INT32 main(VOID)
{
// unsigned char i;
PROTECT_REG
(
PWRCON |= XTL12M_EN;
while((CLKSTATUS & XTL12M_STB) == 0);
CLKSEL0 = (CLKSEL0 & (~HCLK)) | HCLK_12M;
P2_PMD=0x5555;
P2_DOUT = 0xff;
)
TMR1Init();
while(1)
{
if(i>7)
i= 0;
}
}
VOID TMR1_IRQHandler(VOID)
{
TISR1 = 1;
P2_DOUT = ~(1UL<<i);
i++;
}
|