BASIC4MCU | AVR 따라하기 | 2015년 강좌 | 102 - [타이머인터럽트-16] 스위치 누를 때마다 1칸씩 좌우시프트
페이지 정보
작성자 키트 작성일2017-08-23 16:45 조회3,522회 댓글0건본문
12345678910111213141516171819202122 //--------------------------------------------------------// CVAVR// [타이머인터럽트-16] 스위치 누를 때마다 1칸씩 좌우시프트//--------------------------------------------------------#include <mega128.h>//char i=0;//interrupt [TIM1_COMPA] void timer1_compa_isr(void){ // 100msif(!PINE.0){ if(++i>7)i=0; }if(!PINE.1){ if(--i<0)i=7; }}//void main(void){PORTE=0xFF; DDRA=0xFF;TCCR1B=0x0B; OCR1A=24999; TIMSK=0x10; //100msSREG|=0x80;while(1){PORTA=0x01<<i;}}cs
1234567891011121314151617181920212223 //--------------------------------------------------------// AVRStudio// [타이머인터럽트-16] 스위치 누를 때마다 1칸씩 좌우시프트//--------------------------------------------------------#include <avr/io.h>#include <avr/interrupt.h>//volatile unsigned char i=0;//ISR(TIMER1_COMPA_vect){ // 100msif(!(PINE&0x01)){ if(++i>7)i=0; }if(!(PINE&0x02)){ if(--i<0)i=7; }}//int main(void){PORTE=0xFF; DDRA=0xFF;TCCR1B=0x0B; OCR1A=24999; TIMSK=0x10; //100msSREG|=0x80;while(1){PORTA=0x01<<i;}}cs
댓글 0
조회수 3,522등록된 댓글이 없습니다.