📄 timer0._c
字号:
#include <iom8v.h>
#include <macros.h>
extern void spark(unsigned char pos,unsigned char num);
unsigned char LedNum[8]={9,8,7,6,5,4,3,2};
#pragma interrupt_handler timer0:10
void timer0(void)
{
static unsigned char cPos=0;
static unsigned char cTimes=0;
cTimes++;
if (cTimes==3)
{
cTimes=0;
cPos++;
}
cPos&=0b00001111;
spark(cPos,LedNum[cPos]);
}
void timer0_init(void)
{
TIMSK|=0x01;
TCCR0=0x03;//分频系数256
TCNT0=0x10;
/*定时中断时间间隔:
TimeInterval=(256-预置数值)*分频系数/主频
注意开启中断
SEI();
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -