본문 바로가기
임베디드.일렉트로닉스/STM32

STM32 DMA 개념잡기.

by i.got.it 2015. 12. 1.

 

STM32F4 의 DMA

F4시리즈의 어플리케이션 노트중, http://www.st.com/stonline/stappl/resourceSelector/app?page=fullResourceSelector&doctype=application_note&SeriesID=1577

 

1. DMA -> http://www.st.com/web/en/resource/technical/document/application_note/DM00046011.pdf 

(응용노트라기 보다는 상세설명)

2. STM32CubeMX로 제공되는 DMA 라이브러리의 설명문 : http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00105879.pdf 

 

1번에서 주요사항들.

 

DMA transfer properties
A DMA transfer is characterized by the following properties:
• DMA stream/channel
• Stream priority
• Source and destination addresses
• Transfer mode
• Transfer size (only when DMA is the flow controller)
• Source/destination address incrementing or non-incrementing
• Source and destination data width
• Transfer type
• FIFO mode
• Source/destination burst size
• Double-buffer mode
• Flow control

 

DMA Controller 기능블럭도.

 

from : http://www.st.com/web/en/resource/technical/document/application_note/DM00046011.pdf  의 페이지7.

 

DMA Stream/Channel

STM32F2/F4에는 2개의 DMA controller가 있고,동시에 동작가능하다. 

각 DMA는 2개의 포트를 갖고있다.

각 DMA는 8개의 Stream 을 갖고있다.

각 Stream은 8개의 선택적 채널(request) 이 있다. 선택은 소프트웨어에서 설정가능하다.

1개의 스트림에서 한번에 1개의 채널(request)만 가능하다. 채널이란 해당 SPI TX 와 같은 식으로 페리페랄들의 포트들을 지정하는것에 해당한다. http://www.st.com/web/en/resource/technical/document/application_note/DM00046011.pdf  의 페이지8 Table.2

 

 

Stream priority

stream 의 우선권은 소프트웨어 설정가능하다. 만일 동일 priority 로 설정하면 번호작은 stream이 우선한다. 즉 stream0이 stream1보다 우선한다.

 

Source and destination address.

DMA전송은 source, destination address 로 정의된다. source와 destination은 AHB 혹은 APB 메모리 영역에 있어야 한다.

 

Transfer mode.

1. periphal -> memory

2. memory -> periphal

3. memory -> memory (DMA2에서만 가능, 이 모드에서는 circular, direct mode는 불가능)

 

Transfet size.

DMA 가 flow controller 일때만 정의된다.

source 에서 destination 으로 전송될 데이터 크기를 정의하는것.

 

Incrementing source/destination address.

DMA가 각 전송이후에 자동으로 source/destination address 증가되도록 설정가능하다.

 

Source and destination data width.

source와 destination 의 데이터 폭은 Byte(8bits), Half-word(16bits), Word(32bits) 3가지 중 하나 설정가능.

 

Transfer Type.

Circular mode : circular buffer 와 continuous data flow 를 핸들링 가능하다.

(DMA_SxNDTR 이 자동으로 이전 프로그램된 값으로 리로드됨.)

Normal mode : DMA_SxNDTR 이 한번 0이 되면 stream 은 disabled 됨.

 

DMA FIFO mode.

각각의 stream 은 4word(4x32bits) FIFO  갖고 있다.

FIFO threshold 는 소프트웨어에서 설정가능하다. 1/4(즉, 4바이트), 1/2(8바이트), 3/4(12바이트), Full(16바이트).

FIFO 사용하지 않는것을 Direct mode라고 한다.

FIFO 사용으로 설정되면, data packing/unpacking 과 Burst mode 를 사용가능하다.

packing/unpacking 설명도 -> http://www.st.com/web/en/resource/technical/document/application_note/DM00046011.pdf   페이지12 Figure.4

 

Source and destination burst size.

data unit 의 4x, 8x, 16x 를 한방에 전송하는것.

data unit은 byte, half-word, word 일 수 있다.

http://www.st.com/web/en/resource/technical/document/application_note/DM00046011.pdf   페이지 13  Figure.5

 

 

Double buffer mode.

2개의 메모리를 교번식 처리하는것.

 

Flow control.

data 전송과 중단을 책임지는 것.

floaw controller는 DMA일수도 있고 peripheral 일수도있다.

1. DMA를 flow controller로 한 경우.

DMA enable하기전에 전송크기를 DMA_SxNDTR 레지스터에 설정해야한다.

2. Peripheral 을 flow controller로 한경우.

전송되어야 할 데이터 수량을 모르는 경우이다. 이는 SD/MMC에서만 지원된다.

 

 

 본 글이 포함된 상위 정리장소 : http://igotit.tistory.com/244 의 STM32

 

 



///467.

댓글



 

비트코인




암호화폐       외환/나스닥/골드       암호화폐/외환/나스닥/골드 암호화폐/외환/나스닥/골드   암호화폐/외환/나스닥/골드
     
현물 |선물 인버스 |선물 USDT       전략매니저(카피트레이딩)     롤오버 이자 없는 스왑프리계좌
( 스왑프리 암호화폐도 거래 가능 )    
MT4, MT5 , cTrader 모두 지원     FTMO 계좌 매매운용. MT4,MT5