BASIC4MCU | 질문게시판 | 답변 : 외부인터럽트와 타이머/카운터 인터럽트를 이용 응용 프로그램 작성
페이지 정보
작성자 master 작성일2018-06-29 23:26 조회7,380회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=5625
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2018-06-29 오후 11:29:30// by Ok-Hyun Park//#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){ // 1msstatic char cnt=0;PORTG=0; // common offswitch(cnt){case 0: PORTC=n/1000; break;case 1: PORTC=n/100%10; break;case 2: PORTC=n/10 %10; break;case 3: PORTC=n %10; break;}PORTG=1<<cnt; // common onif(++cnt>3)cnt=0;}//int main(void){DDRA=0xFF; DDRC=0xFF; DDRG=0x0F;TCCR0=0x0C; OCR0=249; TIMSK=2; //16000000/ 64/(1+249)=1000Hz=1msEICRB=0xAA; EIMSK=0xF0;sei();while(1){}}
댓글 0
조회수 7,380등록된 댓글이 없습니다.