■DMA Interrupt■
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | #if EXAMPLE == 360 void MemFill(unsigned long ptr, unsigned long pattern, int size) { int i; unsigned long *data; data = (unsigned long *)ptr; for (i=0; i<size;i++) *data++ = pattern; } void MemDump(unsigned long ptr, int size) { int i; unsigned long *data; data = (unsigned long *)ptr; Uart_Printf("\n"); Uart_Printf("*** Dump Memory from [0x%08x] to [0x%08x] : \n",ptr, (unsigned long *)ptr+size); for (i=0; i<size;i++) { if ( !(i%4) ) Uart_Printf("\n [0x%08x] : ",data); Uart_Printf("0x%08x ",*data++); } Uart_Printf("\n"); } #define pISR_DMA0 (*(unsigned *)(0x33ffff64)) static unsigned long src = 0x33000000; static unsigned long dst = 0x33100000; static unsigned int size = 12; //word size unsigned long pattern; static void DMA0_interrupt() { rINTSUBMSK |=(0<<18); rINTMSK1 |=(1<<17); rSUBSRCPND |= 0x1<<18; rSRCPND1|=(1<<17); //clear rINTPND1 |=(1<<17); //clear Uart_Send_String("\n###DMA START ...!!"); MemDump(dst,size); rDMASKTRIG0 |= 0x1 <<2; rINTSUBMSK &=~(1<<18); rINTMSK1 &=~(1<<17); } void Main(void) { rDMASKTRIG0=0x0; //src , dest init rDISRC0 = src; rDIDST0 = dst; //disrcc , didstc init rDISRCC0 &= ~0x3; rDIDSTC0 &= ~0x7; //dcon init rDCON0 = (1<<31) | (1<<30) | (1<<29) |(0<<28) | (1<<27)| (1<<24) | (0<<23)|(0<<22) | (0<<20)|(size*4<<0); //S/W request mode;0 rDMAREQSEL0= (0x0<<0); MemFill(src,0x00000000,size); MemFill(dst,0x00000000,size); pattern = 0x5555aaaa; MemFill(src,pattern,size); //src malloc; MemDump(src,size); //on_off mode ; sw trigger(start) rDMASKTRIG0 = (1<<1) | (1<<0); //interrupt handler set pISR_DMA0= (unsigned int)DMA0_interrupt; rINTSUBMSK &=~(0<<18); rINTMSK1 &=~(1<<17); } # endif | cs |
1.시작지점과 목적지점의 주소를 입력
rDISRC0 = src;
rDIDST0 = dst;
rDISRCC0 &= ~0x3;
rDIDSTC0 &= ~0x7;
2. DCON0 설정
/*setting for S/W DMA request
DCON0 : Handshake[31-1], HCLK[30-1], INT mode[29-1], Single Unit[28-0], Whole service[27-1],
HW_select[26:24], S/W trigger[23-0], Auto Reload ON[22-0], Byte size[21:20](Note: Word size<->Byte size)*/
3. 소프트웨어 인터럽트로 설정
rDMAREQSEL0 = (0x0<<0);
4. 트리거 설정, start =>소프트웨어 인터럽트
rDMASKTRIG0 = (1<<1) | (1<<0);
5.
rINTSUBMSK DMA모드로 설정
rINTMSK1 &=~(1<<17); interrupt 허용
'ARM Device' 카테고리의 다른 글
[ARM 디바이스 제어_Day6~10]Mini_project-무한의 계단 게임 (0) | 2018.11.23 |
---|---|
[ARM 디바이스 제어_Day5]Touch Screen (0) | 2018.11.18 |
[ARM 디바이스 제어_Day4]DMA+Timer,DMA+Uart (0) | 2018.11.18 |
[ARM 디바이스 제어_Day2]key, Uart interrupt (0) | 2018.11.18 |
[ARM 디바이스 제어_Day1]Timer (0) | 2018.11.18 |