BASIC4MCU | 질문게시판 | 답변 : AVR 인터럽트 질문드립니다 ㅠㅠ
페이지 정보
작성자 master 작성일2019-04-30 20:14 조회3,382회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=8398
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2019-04-30 오후 8:16:11// by Ok-Hyun Park//int main(void){unsigned char key;Initialize_MCU();Delay_ms(50); Initialize_LCD(); Initialize_TFT_LCD();LCD_string(0x80," OK-STM767 V1.0 ");LCD_string(0xC0," Exp09_1.c ");Beep();TFT_string(1,4,White,Magenta," SysTick 타이머 인터럽트 이용 LED 점멸 ");TFT_string(10,10,Green,Black," 50ms ON/ 50ms OFF");TFT_string(7,16,White,Black,"KEY1-50ms 주기 인터럽트");TFT_string(7,19,White,Black,"KEY2-100ms 주기 인터럽트");SysTick->CTRL=0x00000001; // 216MHz/8=27MHz,enable SysTick and interruptwhile(1){key=Key_input();switch(key){case KEY1: LED_on(); Display_key(KEY1); TFT_string(10,10,Green,Black," 50ms ON/ 50ms OFF"); Delay_ms( 50); LED_off(); break;case KEY2: LED_on(); Display_key(KEY2); TFT_string(10,10,Green,Black,"100ms ON/100ms OFF"); Delay_ms(100); LED_off(); break;}}}
위는 질문 소스입니다.
아래 코드로 돌려보세요
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2019-04-30 오후 8:21:08// by Ok-Hyun Park//int main(void){unsigned char key,old_mode=0,mode=0;Initialize_MCU();Delay_ms(50); Initialize_LCD(); Initialize_TFT_LCD();LCD_string(0x80," OK-STM767 V1.0 ");LCD_string(0xC0," Exp09_1.c ");Beep();TFT_string(1,4,White,Magenta," SysTick 타이머 인터럽트 이용 LED 점멸 ");TFT_string(10,10,Green,Black," 50ms ON/ 50ms OFF");TFT_string(7,16,White,Black,"KEY1-50ms 주기 인터럽트");TFT_string(7,19,White,Black,"KEY2-100ms 주기 인터럽트");SysTick->CTRL=0x00000001; // 216MHz/8=27MHz,enable SysTick and interruptwhile(1){key=Key_input();switch(key){case KEY1: mode=1; break;case KEY2: mode=2; break;}//if(old_mode!=mode){ old_mode=mode;if(mode==1){ Display_key(KEY1); TFT_string(10,10,Green,Black," 50ms ON/ 50ms OFF"); }if(mode==2){ Display_key(KEY2); TFT_string(10,10,Green,Black,"100ms ON/100ms OFF"); }}//LED_on();if(mode==1)Delay_ms( 50);if(mode==2)Delay_ms(100);LED_off();}}
댓글 0
조회수 3,382등록된 댓글이 없습니다.