tc.c

来自「在atmega128中实现中断」· C语言 代码 · 共 27 行

C
27
字号
#include<iom128v.h>
#include<macros.h>
unsigned char uc_Led;
#pragma interrupt_handler timer0_OVF:17
void timer0_OVF(void)
{
 PORTB=uc_Led;
 OCR1AH=0x00;
 OCR1AL=0xC3;
 uc_Led++;
 if(uc_Led==255)
 uc_Led=0;
}

void main(void)
{
 DDRB=0xff;
 SREG=0x80;
 TIMSK=0x03; 
 OCR1AH=0x00;
 OCR1AL=0xC3;
 TCCR0=0x2F;
 uc_Led=0;
 while(1);
}
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?