본문 바로가기
Development Solutions/Embedded System

ARM Cortex M3 Programming3 - Interrupts, NVIC, DMA (ARM Cortex M3 프로그래밍3 - 인터럽트, NVIC, DMA)

by Dev Diary Hub 2022. 8. 20.
반응형

ARM Cortex M3 Programming3 - Interrupts, NVIC, DMA

ARM Cortex M3 프로그래밍3 - 인터럽트, NVIC, DMA

 

2022.08.20 - [Development Solutions/Embedded System] - ARM Cortex M3 Programming2 - Counters, Timers (ARM Cortex M3 프로그래밍2 - 카운터, 타이머)

 

ARM Cortex M3 Programming2 - Counters, Timers (ARM Cortex M3 프로그래밍2 - 카운터, 타이머)

ARM Cortex M3 Programming2 - Counters, Timers ARM Cortex M3 프로그래밍2 - 카운터, 타이머 2022.08.20 - [Development Solutions/Embedded System] - ARM Cortex M3 Programming1 - Overview, GPI..

studiodoc.tistory.com

 

(추천) Qt QML과 C++로 시작하는 크로스플랫폼 앱 개발 강의 - 입문편

https://inf.run/3XmSH

 

Qt QML과 C++로 시작하는 크로스플랫폼 앱 개발 - 입문편 강의 - 인프런

Qt QML과 C++를 사용하여 크로스플랫폼 애플리케이션 개발에 입문할 수 있습니다. 해당 강의에서는 윈도우 응용 프로그램 타겟으로 개발을 진행합니다., 강의 주제 📖 이 강의를 통해 참가자들은

www.inflearn.com

 

 

- 인터럽트

: Fetch-Decode-Excute 방식대로 수행하는 것이 지속 불가능한 예외를 처리

: 인터럽트 체크는 파이프라인 각 단계 직후마다 수행

: M3는 Exception Vector를 이용하여 HW적으로 예외 번호에 해당하는 예외 처리

: Vectoring: 예외 처리로 뛰는 과정. 즉, 저장된 예외처리 주소(Handler Addr.)를 HW적으로 보냄

: 모든 인터럽트는 CPU 외부에서 발생. 저전력 상태의 CPU 깨움

 

- NVIC

: Nested Vectored Interrupt Controller

: M3에선 NVIC 전용 함수들이 CMSIS로 제공됨

: 외부 GPIO를 그룹화하여 해당 번호마다 외부 인터럽트 소스로 사용

 

- 인터럽트 우선순위

: Nesting: 수행 중인 인터럽트보다 높은 우선순위의 인터럽트 요청 시, 기존 인터럽트는 일시정지하고 요청된 인터럽트부터 수행 

- 지나친 Nesting은 시스템 스택에 악영향! 해결책?

-> 우선 순위를 정수부와 소수부로 나눔 

-> 정수부 우선순위가 높을 때만 선점(Nesting)

-> 정수부 우선순위가 같거나 낮을 때는 보관(Pending)

: Pending: 수행 중인 인터럽트보다 낮은 우선 순위의 인터럽트 요청 시, 기존 인터럽트 완료 후에 요청된 인터럽트 수행

반응형

- DMA

: CPU는 내부 동작중에 외부 메모리 버스를 사용하지 않는데, 이 시간동안 DMA가 버스를 사용

: 수행절차?

- [0] CPU가 DMA 작업 설정

- [1] DMA가 CPU에게 메모리 버스 제어권을 요구 (Bus Request)

- [2] CPU가 DMA에 버스 제어권 양보 (Bus Ack)

- [3] DMA가 버스를 이용하여 1 UNIT만큼 전송시킴

- [4] 전송시킨 후 CPU에 제어권 반납

- [5] [1]~[4] 반복, 즉 DMA는 1 UNIT만 전송시키고 다시 버스 제어권 요청 반복

: M3에서는 DMA마다 1~5채널이 있어서, 채널 우선순위에 따라 Arbiter가 제어함

:* Source장치: 시작 주소, UNIT크기, 주소 모드(증가,고정)

|

V

     DMA: Mem to Mem인지 Mem to Peripheral인지, 전송 횟수(COUNT) , Circular모드, 채널 우선순위

|

*Destination장치: Source와 동일

: 주소 증가모드?

- 증가모드: 소스, 목적지가 동일한 크기로 데이터 전송 (Mem to Mem)

- 고정모드: 소스, 목적지가 주소를 고정시켜서 데이터 전송 (Mem to Peri)

메모리-> UART로 100B 데이터 전송하려면?

메모리(증가모드) -> UART(고정모드)로 1 UNIT을 100번(COUNT) 전송!

>이처럼, DMA가 동일한 주소에서 데이터를 R/W하는 경우 증가모드 설정해야함.

>소스와 목적지의 주소모드에 따라 FIX(고정), INC(증가)로 설정

: ->CCRx: 각 채널에 대해 DMA 동작을 위한 기본 설정

: ->CNDTRx: 각 채널의 전송 횟수 설정(16bit이므로 최대 65535)

: ->CMARx: 각 채널의 Mem 주소 저장

: ->CPARx: 각 채널의 Peri 주소 저장

: ->ISR: 각 채널에 대한 상태 flag 확인

: ->IFCR: 각 상태 flag를 clear (=1)

 

(

- Interrupt

: Handles unsustainable exceptions that are not performed in the Fetch-Decode-Excute method.

: Interrupt check is performed immediately after each stage of the pipeline

: M3 handles the exception corresponding to the exception number in HW using the Exception Vector

: Vectoring: The process of jumping to exception handling. That is, the stored exception handling address (Handler Addr.) is sent as HW.

: All interrupts are generated outside the CPU. Wake up CPU from low power state



- NVIC

: Nested Vectored Interrupt Controller

: In M3, NVIC-only functions are provided as CMSIS

: By grouping external GPIOs, each number is used as an external interrupt source



- Interrupt Priority

: Nesting: When requesting an interrupt with a higher priority than the current interrupt, the existing interrupt is paused and the requested interrupt is executed.

- Excessive nesting adversely affects the system stack! solution?

-> Divide the priority into integer part and decimal part

-> Preemption only when integer part priority is high (Nesting)

-> When the priority of the integer part is the same or lower, it is stored (Pending)

: Pending: When an interrupt with a lower priority than the current interrupt is requested, the requested interrupt is executed after the existing interrupt is completed



- DMA

: The CPU does not use the external memory bus during internal operation. During this time, the DMA uses the bus.

: Procedure?

- [0] CPU set DMA operation

- [1] DMA requests the CPU to control the memory bus (Bus Request)

- [2] CPU yields bus control to DMA (Bus Ack)

- [3] DMA transmits 1 unit by bus

- [4] Return control to CPU after sending

- [5] Repeat [1]~[4], that is, DMA transfers only 1 unit and repeats the request for bus control right again

: In M3, there are 1~5 channels for each DMA, and the arbiter controls it according to the channel priority.

:* Source device: start address, unit size, address mode (increment, fixed)

|

V

     DMA: Mem to Mem or Mem to Peripheral, transmission count (COUNT) , Circular mode, channel priority

|

V

*Destination device: Same as Source

: Address increment mode?

- Incremental mode: Source and destination data are transmitted in the same size (Mem to Mem)

- Fixed mode: source and destination fixed addresses to transmit data (Mem to Peri)

Memory -> To transfer 100B data by UART?

Memory (increment mode) -> UART (fixed mode) transmits 1 unit 100 times (COUNT)!

>In this way, when DMA R/W data from the same address, the incremental mode must be set.

>Set as FIX (fixed), INC (increase) according to the address mode of the source and destination

: ->CCRx: Default setting for DMA operation for each channel

: ->CNDTRx: Set the number of transmissions for each channel (up to 65535 because it is 16bit)

: ->CMARx: Save Mem address of each channel

: ->CPARx: Store the Peri address of each channel

: ->ISR: Check status flag for each channel

: ->IFCR: clear each status flag (=1)

)

 

 

 

 

 

ARM 매뉴얼 보기

 

https://developer.arm.com/ip-products/processors/cortex-m/cortex-m3

 

Cortex-M3

Important Information for the Arm website. This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn

developer.arm.com

 

본 게시글은 개인 공부용으로 작성하여 내용의 퀄리티가 부족할 수 있습니다. 

상세한 회로도나 스펙을 보시려면 arm 매뉴얼 참고 바랍니다.

(This post was written for personal study, so the quality of the content may be lacking.

For detailed circuit diagrams and specifications, please refer to the arm manual.)

 

(추천) Qt QML과 C++로 시작하는 크로스플랫폼 앱 개발 강의 - 입문편

https://inf.run/3XmSH

 

Qt QML과 C++로 시작하는 크로스플랫폼 앱 개발 - 입문편 강의 - 인프런

Qt QML과 C++를 사용하여 크로스플랫폼 애플리케이션 개발에 입문할 수 있습니다. 해당 강의에서는 윈도우 응용 프로그램 타겟으로 개발을 진행합니다., 강의 주제 📖 이 강의를 통해 참가자들은

www.inflearn.com

 

반응형