?? timer.c
字號:
//:rc:8M
//ic atmegal 8l
#include <avr/io.h>
#include <avr/interrupt.h>
#define uchar unsigned char
#define uint unsigned int
unsigned char timer=0;
void delay(unsigned int x)
{
while(x)x--;
}
SIGNAL(SIG_OVERFLOW1)
{
TCNT1=61712;
timer++;
if(timer>=150) //〈256 //改變時間
{
PORTB=0x01^PORTB; //改變引腳
timer=0;
}
}
int main (void)
{
DDRB=0xff;
PORTB=0Xff;//1111,1111
sei();
TCCR1A=0X00;
TCCR1B=(1<<CS10);
TIMSK|=(1<<TOIE1);
TCNT1=61712;
while(1)
{
}
return (0);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -