FND출력문제
페이지 정보
작성자 MCU새우 작성일18-06-30 00:41 조회5,005회 댓글0건본문
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
char seg[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x27,0x7f,0x6f,0x77,0x7c,0x58,0x5e,0x79,0x71,0};
int n=0;
ISR(INT4_vect){
PORTA<<=1; if(PORTA==0)PORTA=0x01;
}
ISR(INT5_vect){
PORTA>>=1; if(PORTA==0)PORTA=0x80;
}
ISR(INT6_vect){
if(++n>9999)n=0;
}
ISR(INT7_vect){
if(--n<0)n=9999;
}
ISR(TIMER0_COMP_vect){
static char cnt=0;
PORTG=0;
switch(cnt){
case 0: PORTC=n %10; break;
case 1: PORTC=n/10 %10; break;
case 2: PORTC=n/100%10; break;
case 3: PORTC=n/1000; break;
}
PORTG=1<<cnt;
if(++cnt>3)cnt=0;
}
int main(void){
DDRA=0xFF; DDRC=0xFF; DDRG=0x0F;
TCCR0=0x0C; OCR0=249; TIMSK=2;
EICRB=0xAA; EIMSK=0xF0;
sei();
while(1){}
}
댓글 : 0
조회수 : 5,005
등록된 댓글이 없습니다.