Professional Documents
Culture Documents
Day 4. Interrupt (p1)
Day 4. Interrupt (p1)
Day 4. Interrupt (p1)
1
DAY-4 : Fundamental Interrupt Programming(1)
Learning Object
How to Design a Control Program That Turns On/Off of 1 LED with a switch using the
polling method
Atlanta, Georgia
CNN Headquarters
Coca-Cola Company Headquarters
Gone with the wind, Filming location
Stone mountain : 8km, 3200 acre, 318m
https://www.gatech.edu/
https://www.youtube.com/watch?v=RKY2z4O8g2w
https://www.youtube.com/watch?v=tv5XT2gVb_I
November 11, 2021 -4-
2
Class-1 : How to design a control program that turns
on/off 1 LED with a switch using the
polling method
Refer p.88
1. 인터럽트 (Interrupt)
• 인터럽트는 프로그램을 실행하는 도중에 예기치 않은 상황이 발생할 경우 현재 실행중인 작업을 즉시 중단하고
발생된 상황을 우선 처리한 후 실행 중이던 작업으로 복귀하여 계속 처리하는 것
2. 인터럽트 발생 종류
• 외부 인터럽트
• 내부 인터럽트
• 소프트웨어 인터럽트
3
Refer p.88
Refer p.88
3. 인터럽트 (interrupt) 처리 방식 (1 of 2)
4
Refer p.88
3. 인터럽트 (interrupt) 처리 방식 (2 of 2) : DAY5
// SYSCFG
SYSCFG->EXTICR[0] = (SYSCFG_EXTICR1_EXTI0_PG | SYSCFG_EXTICR1_EXTI1_PG);
Refer p.88
4. 인터럽트 요청 시 처리 과정
• 인터럽트 발생 인터럽트 요구
• 인터럽트 처리 루틴 수행
5
1. Create a Project Refer p.88
2. MCU/MPU Selector
-Core : Arm Cortex-M4
-Series : STM32F4
-Line : STM32F429/439
-Package : LQFP144
-Next
-Project Name : INT_EX4_1
-Finish
It does not matter whether the clock setting is the default setting value
6
3. Pinout & Configuration (1 of 3) Refer p.88
7
3. Pinout & Configuration (3 of 3) Refer p.88
main.h (1 of 1)
8
main.c (1 of 4) Refer p.89
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
if(HAL_GPIO_ReadPin (GPIOG, GPIO_PIN_0) == HAL_OK)
HAL_GPIO_WritePin (GPIOD, GPIO_PIN_0, GPIO_PIN_SET);
This example uses CubeMX to set GPIOD0 and GPIOG0/1 to generate code, so no separate code is
needed.
9
Refer p.91
1. Project
-Same as Example INT_EX1
2. Clock Configuration
-Same as Example INT_EX1
main.h (1 of 1)
10
main.c (1 of 2) Refer p.91
int main(void)
{
__HAL_RCC_GPIOD_CLK_ENABLE();
LEDConfig.Mode = GPIO_MODE_OUTPUT_PP;
LEDConfig.Pin = GPIO_PIN_0;
LEDConfig.Speed = GPIO_SPEED_FREQ_LOW;
LEDConfig.Pull = GPIO_NOPULL;
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
if (HAL_GPIO_ReadPin (GPIOG, GPIO_PIN_0) == HAL_OK)
HAL_GPIO_WritePin (GPIOD, GPIO_PIN_0, GPIO_PIN_SET);
11
Class-3 : How to design a control program that turns
on/off 1 LED with a switch using the polling
method
Refer p.95
1. Project
-Same as Example INT_EX1
2. Clock Configuration
-Same as Example INT_EX1
12
5. Coding : main.h & main.c Refer p.95
main.h (1 of 1)
RCC->AHB1ENR = (1<<0x03)|(1<<0x06);
RCC->APB2ENR |= (1<<14); RCC->AHB1ENR 1 1 1
8 4 2 1
// GPIOD PD0 output
GPIOD->MODER |= 0x00005555; Refer p.106
GPIOG->OSPEEDR &= 0x00000000;
GPIOG->PUPDR &= 0x00000000;
13
Refer p.73-76
RCC->AHB1ENR 1 1
8 4 2 1
/* Infinite loop */
/* USER CODE BEGIN WHILE */
14
Summary : Day-4
15