BASIC4MCU | 질문게시판 | 답변 : 아트메가 128 코딩 질문드립니다..
페이지 정보
작성자 master 작성일2018-06-18 00:07 조회11,259회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=1948
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2018-06-18 오전 12:08:35// by Ok-Hyun Park//#include <avr/io.h>#include <avr/interrupt.h>//volatile unsigned char msec=0,cnt=0;//ISR(TIMER1_COMPA_vect){ msec=1; }//int main(void){DDRA=0xFF;TCCR1B=0x09; OCR1A=15999; TIMSK=0x10;sei();while(1){if(msec){ msec=0;if(cnt++>=100){ cnt=0; PORTA^=0xFF; }}}}
타이머1 1ms CTC 비교 A매치 인터럽트입니다.
아래 설정예도 참고하세요
// 타이머1 A매치 인터럽트TCCR1B=0x09; OCR1A=79; TIMSK=0x10; //5usTCCR1B=0x09; OCR1A=159; TIMSK=0x10; //10usTCCR1B=0x09; OCR1A=319; TIMSK=0x10; //20usTCCR1B=0x09; OCR1A=399; TIMSK=0x10; //25usTCCR1B=0x09; OCR1A=463; TIMSK=0x10; //29usTCCR1B=0x09; OCR1A=479; TIMSK=0x10; //30usTCCR1B=0x09; OCR1A=639; TIMSK=0x10; //40usTCCR1B=0x09; OCR1A=799; TIMSK=0x10; //50usTCCR1B=0x09; OCR1A=927; TIMSK=0x10; //58usTCCR1B=0x09; OCR1A=959; TIMSK=0x10; //60usTCCR1B=0x09; OCR1A=1119; TIMSK=0x10; //70usTCCR1B=0x09; OCR1A=1279; TIMSK=0x10; //80usTCCR1B=0x09; OCR1A=1439; TIMSK=0x10; //90usTCCR1B=0x09; OCR1A=1599; TIMSK=0x10; //100usTCCR1B=0x09; OCR1A=3199; TIMSK=0x10; //200usTCCR1B=0x09; OCR1A=3999; TIMSK=0x10; //250usTCCR1B=0x09; OCR1A=4799; TIMSK=0x10; //300usTCCR1B=0x09; OCR1A=6399; TIMSK=0x10; //400usTCCR1B=0x09; OCR1A=7999; TIMSK=0x10; //500usTCCR1B=0x09; OCR1A=9599; TIMSK=0x10; //600usTCCR1B=0x09; OCR1A=11199; TIMSK=0x10; //700usTCCR1B=0x09; OCR1A=12799; TIMSK=0x10; //800usTCCR1B=0x09; OCR1A=14399; TIMSK=0x10; //900usTCCR1B=0x09; OCR1A=15999; TIMSK=0x10; //1msTCCR1B=0x09; OCR1A=31999; TIMSK=0x10; //2msTCCR1B=0x09; OCR1A=39999; TIMSK=0x10; //2.5msTCCR1B=0x09; OCR1A=47999; TIMSK=0x10; //3msTCCR1B=0x09; OCR1A=63999; TIMSK=0x10; //4msTCCR1B=0x0A; OCR1A=9; TIMSK=0x10; //5us //16000000Hz/8/(9+1)=200000Hz=5usTCCR1B=0x0A; OCR1A=19; TIMSK=0x10; //10usTCCR1B=0x0A; OCR1A=39; TIMSK=0x10; //20usTCCR1B=0x0A; OCR1A=49; TIMSK=0x10; //25usTCCR1B=0x0A; OCR1A=57; TIMSK=0x10; //29usTCCR1B=0x0A; OCR1A=59; TIMSK=0x10; //30usTCCR1B=0x0A; OCR1A=79; TIMSK=0x10; //40usTCCR1B=0x0A; OCR1A=99; TIMSK=0x10; //50usTCCR1B=0x0A; OCR1A=115; TIMSK=0x10; //58usTCCR1B=0x0A; OCR1A=119; TIMSK=0x10; //60usTCCR1B=0x0A; OCR1A=139; TIMSK=0x10; //70usTCCR1B=0x0A; OCR1A=159; TIMSK=0x10; //80usTCCR1B=0x0A; OCR1A=179; TIMSK=0x10; //90usTCCR1B=0x0A; OCR1A=199; TIMSK=0x10; //100usTCCR1B=0x0A; OCR1A=399; TIMSK=0x10; //200usTCCR1B=0x0A; OCR1A=499; TIMSK=0x10; //250usTCCR1B=0x0A; OCR1A=599; TIMSK=0x10; //300usTCCR1B=0x0A; OCR1A=799; TIMSK=0x10; //400usTCCR1B=0x0A; OCR1A=999; TIMSK=0x10; //500usTCCR1B=0x0A; OCR1A=1199; TIMSK=0x10; //600usTCCR1B=0x0A; OCR1A=1399; TIMSK=0x10; //700usTCCR1B=0x0A; OCR1A=1599; TIMSK=0x10; //800usTCCR1B=0x0A; OCR1A=1799; TIMSK=0x10; //900usTCCR1B=0x0A; OCR1A=1999; TIMSK=0x10; //1msTCCR1B=0x0A; OCR1A=3999; TIMSK=0x10; //2msTCCR1B=0x0A; OCR1A=4999; TIMSK=0x10; //2.5msTCCR1B=0x0A; OCR1A=5999; TIMSK=0x10; //3msTCCR1B=0x0A; OCR1A=7999; TIMSK=0x10; //4msTCCR1B=0x0A; OCR1A=9999; TIMSK=0x10; //5msTCCR1B=0x0A; OCR1A=11999; TIMSK=0x10; //6msTCCR1B=0x0A; OCR1A=13999; TIMSK=0x10; //7msTCCR1B=0x0A; OCR1A=15999; TIMSK=0x10; //8msTCCR1B=0x0A; OCR1A=17999; TIMSK=0x10; //9msTCCR1B=0x0A; OCR1A=19999; TIMSK=0x10; //10msTCCR1B=0x0A; OCR1A=31999; TIMSK=0x10; //16msTCCR1B=0x0A; OCR1A=39999; TIMSK=0x10; //20msTCCR1B=0x0A; OCR1A=49999; TIMSK=0x10; //25msTCCR1B=0x0A; OCR1A=59999; TIMSK=0x10; //30msTCCR1B=0x0A; OCR1A=15359; TIMSK=0x10; //14745600Hz/8/(15360)=120Hz=0.008333ms,클럭0.5425347222usTCCR1B=0x0B; OCR1A=4; TIMSK=0x10; //20usTCCR1B=0x0B; OCR1A=9; TIMSK=0x10; //40usTCCR1B=0x0B; OCR1A=14; TIMSK=0x10; //60usTCCR1B=0x0B; OCR1A=19; TIMSK=0x10; //80usTCCR1B=0x0B; OCR1A=24; TIMSK=0x10; //100usTCCR1B=0x0B; OCR1A=49; TIMSK=0x10; //200usTCCR1B=0x0B; OCR1A=74; TIMSK=0x10; //300usTCCR1B=0x0B; OCR1A=99; TIMSK=0x10; //400usTCCR1B=0x0B; OCR1A=124; TIMSK=0x10; //500usTCCR1B=0x0B; OCR1A=149; TIMSK=0x10; //600usTCCR1B=0x0B; OCR1A=174; TIMSK=0x10; //700usTCCR1B=0x0B; OCR1A=199; TIMSK=0x10; //800usTCCR1B=0x0B; OCR1A=224; TIMSK=0x10; //900usTCCR1B=0x0B; OCR1A=249; TIMSK=0x10; //1msTCCR1B=0x0B; OCR1A=499; TIMSK=0x10; //2msTCCR1B=0x0B; OCR1A=624; TIMSK=0x10; //2.5msTCCR1B=0x0B; OCR1A=749; TIMSK=0x10; //3msTCCR1B=0x0B; OCR1A=999; TIMSK=0x10; //4msTCCR1B=0x0B; OCR1A=1249; TIMSK=0x10; //5msTCCR1B=0x0B; OCR1A=1499; TIMSK=0x10; //6msTCCR1B=0x0B; OCR1A=1749; TIMSK=0x10; //7msTCCR1B=0x0B; OCR1A=1999; TIMSK=0x10; //8msTCCR1B=0x0B; OCR1A=2249; TIMSK=0x10; //9msTCCR1B=0x0B; OCR1A=2499; TIMSK=0x10; //10msTCCR1B=0x0B; OCR1A=3999; TIMSK=0x10; //16msTCCR1B=0x0B; OCR1A=4999; TIMSK=0x10; //20msTCCR1B=0x0B; OCR1A=6249; TIMSK=0x10; //25msTCCR1B=0x0B; OCR1A=7499; TIMSK=0x10; //30msTCCR1B=0x0B; OCR1A=9999; TIMSK=0x10; //40msTCCR1B=0x0B; OCR1A=12499; TIMSK=0x10; //50msTCCR1B=0x0B; OCR1A=14999; TIMSK=0x10; //60msTCCR1B=0x0B; OCR1A=17499; TIMSK=0x10; //70msTCCR1B=0x0B; OCR1A=19999; TIMSK=0x10; //80msTCCR1B=0x0B; OCR1A=22499; TIMSK=0x10; //90msTCCR1B=0x0B; OCR1A=24999; TIMSK=0x10; //100msTCCR1B=0x0B; OCR1A=49999; TIMSK=0x10; //200msTCCR1B=0x0B; OCR1A=62499; TIMSK=0x10; //250msTCCR1B=0x0C; OCR1A=4; TIMSK=0x10; //80usTCCR1B=0x0C; OCR1A=24; TIMSK=0x10; //400usTCCR1B=0x0C; OCR1A=49; TIMSK=0x10; //800usTCCR1B=0x0C; OCR1A=124; TIMSK=0x10; //2msTCCR1B=0x0C; OCR1A=249; TIMSK=0x10; //4msTCCR1B=0x0C; OCR1A=374; TIMSK=0x10; //6msTCCR1B=0x0C; OCR1A=499; TIMSK=0x10; //8msTCCR1B=0x0C; OCR1A=624; TIMSK=0x10; //10msTCCR1B=0x0C; OCR1A=999; TIMSK=0x10; //16msTCCR1B=0x0C; OCR1A=1249; TIMSK=0x10; //20msTCCR1B=0x0C; OCR1A=1874; TIMSK=0x10; //30msTCCR1B=0x0C; OCR1A=2499; TIMSK=0x10; //40msTCCR1B=0x0C; OCR1A=3124; TIMSK=0x10; //50msTCCR1B=0x0C; OCR1A=3749; TIMSK=0x10; //60msTCCR1B=0x0C; OCR1A=4374; TIMSK=0x10; //70msTCCR1B=0x0C; OCR1A=4999; TIMSK=0x10; //80msTCCR1B=0x0C; OCR1A=5624; TIMSK=0x10; //90msTCCR1B=0x0C; OCR1A=6249; TIMSK=0x10; //100msTCCR1B=0x0C; OCR1A=12499; TIMSK=0x10; //200msTCCR1B=0x0C; OCR1A=15624; TIMSK=0x10; //250msTCCR1B=0x0C; OCR1A=18749; TIMSK=0x10; //300msTCCR1B=0x0C; OCR1A=24999; TIMSK=0x10; //400msTCCR1B=0x0C; OCR1A=31249; TIMSK=0x10; //500msTCCR1B=0x0C; OCR1A=37499; TIMSK=0x10; //600msTCCR1B=0x0C; OCR1A=43749; TIMSK=0x10; //700msTCCR1B=0x0C; OCR1A=49999; TIMSK=0x10; //800msTCCR1B=0x0C; OCR1A=56249; TIMSK=0x10; //900msTCCR1B=0x0C; OCR1A=62499; TIMSK=0x10; //1secTCCR1B=0x0D; OCR1A=124; TIMSK=0x10; //8msTCCR1B=0x0D; OCR1A=249; TIMSK=0x10; //16msTCCR1B=0x0D; OCR1A=624; TIMSK=0x10; //40msTCCR1B=0x0D; OCR1A=1249; TIMSK=0x10; //80msTCCR1B=0x0D; OCR1A=3124; TIMSK=0x10; //200msTCCR1B=0x0D; OCR1A=6249; TIMSK=0x10; //400msTCCR1B=0x0D; OCR1A=9374; TIMSK=0x10; //600msTCCR1B=0x0D; OCR1A=12499; TIMSK=0x10; //800msTCCR1B=0x0D; OCR1A=15624; TIMSK=0x10; //1secTCCR1B=0x0D; OCR1A=31249; TIMSK=0x10; //2secTCCR1B=0x0D; OCR1A=46874; TIMSK=0x10; //3secTCCR1B=0x0D; OCR1A=62499; TIMSK=0x10; //4sec
댓글 0
조회수 11,259등록된 댓글이 없습니다.