BASIC4MCU | 질문게시판 | 답변 : 아트메가128>LED불 켜기 질문입니다.
페이지 정보
작성자 master 작성일2019-11-11 11:04 조회6,960회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=10656
본문
#include <avr/io.h>
#define F_CPU 16000000UL // 딜레이 함수를 사용하지 않으면 선언이 없어도 됨
#include <util/delay.h> // 딜레이 함수를 사용하지 않으면 선언이 없어도 됨
#include <avr/interrupt.h>volatile int count; // (컴파일러에서 초기값을 주지만) 습관적으로 count=0; 로 초기값을 설정하는 것이 좋음
ISR(TIMER0_OVF_vect){
TCNT0=0; // 오버플로우 인터럽트 발생조건이 TCNT0=0 이므로 생략가능
if(++count>=11){
PORTA=0xf0; _delay_ms(500);
PORTA=0x00; _delay_ms(500);
}else {
PORTA=0x0f; _delay_ms(500);
PORTA=0x00; _delay_ms(500);
}}
int main (){
DDRA=0xff;
TCNT0=0; // 리셋 디폴트 값과 같으므로 생략가능
TCCR0=7;
sei();
TIMSK=1;
while (1)
;
}
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2019-11-11 오전 11:03:31// by Ok-Hyun Park//#include <avr/io.h>#include <avr/interrupt.h>//volatile int count=0;//ISR(TIMER0_OVF_vect){ // 16.384msif(++count>=30){ count=0; // // 16.384ms * 30 = 491.52msif(PORTA!=0xF0)PORTA=0xF0;else PORTA=0x0F;}}//int main(){DDRA=0xFF;TCCR0=7; TIMSK=1; sei();while(1);}
댓글 0
조회수 6,960등록된 댓글이 없습니다.