BASIC4MCU | 질문게시판 | 답변 : 인터럽트 3개를 쓰고 싶은데 코드를 못 짜겠습니다.
페이지 정보
작성자 master 작성일2018-12-20 20:50 조회7,474회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=7133
본문
SIGNAL(SIG_OUTPUT_COMPARE0){}
달랑 이 코드만 올리면 답변도 심플하게 작성될 수 밖에 없습니다.
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2018-12-20 오후 8:55:54// by Ok-Hyun Park//#include <avr/io.h>#include <avr/interrupt.h>#define F_CPU 16000000UL // 16 MHz#include <util/delay.h>//volatile char mode=0; // 전역변수//void func1(){}//void func2(){}//void func3(){}//SIGNAL(SIG_OUTPUT_COMPARE0){ mode=1; }SIGNAL(SIG_OUTPUT_COMPARE1){ mode=2; }SIGNAL(SIG_OUTPUT_COMPARE2){ mode=3; }//int main(){EICRA=0xAA; EIFR=0xFF; EIMSK=0x07; //falling edgeSREG=0x80;while(1){if(mode==1){ func1(); }if(mode==2){ func2(); }if(mode==3){ func3(); }}}
댓글 0
조회수 7,474등록된 댓글이 없습니다.