自动驾驶 定时器
#include
#include
#define uchar unsigned char
#define uchar unsigned int
uchar flag;
void main()
{
TCCR1A = 0;//WGM11、10清零
TCCR1B = 0x04; //256分频
TCNT1H = 0x8f;
TCNT1L = 0x80;
tiMSK = BIT(2);
SREG = BIT(7);
DDRA=0xff;
PORTA=0;
while(1)PORTA=flag;
}
#pragma interrupt_handler timer1:iv_TIMER1_OVF
void timer1()
{
TCNT1H = 0x8f;
TCNT1L = 0x80;
flag++;
if(flag == 100)flag=0;
}
回帖(3)
2018-12-7 00:24:11
看看了
看看了
举报
2018-12-7 00:24:25
单片机,遍地啊
单片机,遍地啊
举报
2018-12-7 23:24:19
会玩才是硬道理!别光嘴巴比比!
会玩才是硬道理!别光嘴巴比比!
举报
更多回帖