Presentation is loading. Please wait.

Presentation is loading. Please wait.

Interrupt Test UNIT 14 로봇 SW 교육원 조용수. 학습 목표 Button Interrupt Uart Interrupt 2.

Similar presentations


Presentation on theme: "Interrupt Test UNIT 14 로봇 SW 교육원 조용수. 학습 목표 Button Interrupt Uart Interrupt 2."— Presentation transcript:

1 Interrupt Test UNIT 14 로봇 SW 교육원 조용수

2 학습 목표 Button Interrupt Uart Interrupt 2

3 Button(EINT0) Interrupt EINT0 인터럽트 활성화 –Interrupt Controller 설정 //NVIC_EnableIRQ(EINT0_IRQn); NVIC->ISER[0] = (0x1 << 2); –GPIO Port 설정 //GPIO_EnableInt(P3, 2, GPIO_INT_FALLING); P3->IEN |= 0x1 << 2 ; P3->IMD &= ~(0x1 << 2); 3

4 Button(EINT0) Interrupt EINT0 Handler 설정 4 ; External Interrupts ; maximum of 32 External Interrupts are possible DCD BOD_IRQHandler DCD WDT_IRQHandler DCD EINT0_IRQHandler DCD EINT1_IRQHandler DCD GPIOP0P1_IRQHandler DCD GPIOP2P3P4_IRQHandler

5 Button(EINT0) Interrupt EINT0 Handler 설정 5 void EINT0_IRQHandler() { int32_t value = P2->PIN; P2->DOUT = ~(value); P3->ISRC = 0x4; }

6 Button(EINT0) Interrupt EINT0 Interrupt Enable 설정 6 int main() { SYS->P3_MFP &= ~(0x0404); SYS->P3_MFP |= SYS_MFP_P32_INT0; //GPIO_SetMode(P3, BIT6, GPIO_PMD_INPUT); P3->PMD &= ~(0x3 << 4); P3->PMD |= (0x3 << 4); //GPIO_EnableInt(P3, 2, GPIO_INT_FALLING); P3->IEN |= 0x1 << 2 ; P3->IMD &= ~(0x1 << 2); //NVIC_EnableIRQ(EINT0_IRQn); NVIC->ISER[0] = (0x1 << 2); while(1) { }

7 Button(EINT0) Interrupt EINT0 De-Bounce 설정 7 int main() { /* Debounce function control */ GPIO->DBNCECON &= ~(0xF); GPIO->DBNCECON |= GPIO_DBCLKSEL_1024; //GPIO_ENABLE_DEBOUNCE(P3, BIT2 ); P3->DBEN |= 0x1 << 2; … while(1) { }

8 UART Interrupt Uart Interrupt 를 이용하여 RX 테스트 8 void UART0_Init() { /* Configure UART0 and set UART0 Baudrate */ UART_Open(UART0, ); //UART0->FCR |= (0x02 << 4); // Fifo Interrupt Trigger : 8 Byte // Receive Interrrupt Enable; UART0->IER |= 0x1; }

9 UART Interrupt Uart Interrupt 를 이용하여 RX 테스트 9 void UART0_IRQHandler() { int value = UART0->ISR ; int count = 0; int ch; if(value & 0x1) { // Receive Data Available count = (UART0->FSR & 0x0F00) >> 8 ; ch =UartRead(); printf("%c", ch); printf(" C:%d\n", count); } if(value & 0x2) { // Transmit Register Empty }

10 UART Interrupt Uart Interrupt Enable 10 int main(void) { int8_t ch; /* Init System, IP clock and multi-function I/O */ SYS_Init(); /* Init UART0 for printf */ UART0_Init(); //NVIC_EnableIRQ(UART0_IRQn); NVIC->ISER[0] = (0x1 << 12); while(1); }

11 GPIO & UART 게임을 Interrupt 로 러시안 룰렛 게임의 버튼 입력을 Interrupt 로 변경 Up/Down 게임에서 Uart Interrupt 를 사용 11

12 GPIO & UART 게임을 Interrupt 로 러시안 룰렛 게임의 버튼 입력을 Interrupt 로 변경 12 void EINT0_IRQHandler() { result --; if(result <= 0) { printf(" You are dead!!! \n"); P2->DOUT = 0x00; result = rand() % 6; printf("Start New Game \n"); } else { P2->DOUT = 0xFF; printf(" You are alive!!! \n"); } // Interrupt Pending Clear P3->ISRC = 0x4; }

13 GPIO & UART 게임을 Interrupt 로 Up/Down 게임에서 Uart Interrupt 를 사용 13 void UART0_IRQHandler() { int value = UART0->ISR ; int count = 0; int ch, input; if(value & 0x1) { // Receive Data Available count = (UART0->FSR & 0x0F00) >> 8 ; printf("Input: "); ch =UART0->DATA; printf("%c", ch); // Game input = ch - 0x30 ; // ASCII To Int if(input > 10) { printf("Please Input Number \n"); }else if(input < result ) { printf(" -> Low !!!\n"); } else if(input > result) { printf(" -> High !! \n"); } else { printf(" Correct!!! %d\n\n", result); result = rand() % 10; printf("Start New Game \n\n"); } if(value & 0x2) { // Transmit Register Empty }

14 GPIO & UART 게임을 Interrupt 로 Up/Down 게임에서 Uart Interrupt 를 사용 14 void UART0_Init() { /* Configure UART0 and set UART0 Baudrate */ UART_Open(UART0, ); // Receive Interrrupt Enable; UART0->IER |= 0x1; } int main(void) { int8_t ch; /* Init System, IP clock and multi-function I/O */ SYS_Init(); UART0_Init(); NVIC->ISER[0] = (0x1 << 12); printf("Start New Game \n\n"); result = rand() % 10; while(1); }


Download ppt "Interrupt Test UNIT 14 로봇 SW 교육원 조용수. 학습 목표 Button Interrupt Uart Interrupt 2."

Similar presentations


Ads by Google