SH7263/SH7203 Group
Data Transfer to On-chip Peripheral Modules with DMAC
REJ06B0734-0100/Rev.1.00 April 2008 Page 12 of 17 4. Sample Program Listing "main.c" (4)
161 /* ----Setting DMA source address register---- */
162 DMAC.SAR1.LONG = (unsigned long)src;
163
164 /* ----Setting DMA reload source address register---- */
165 DMAC.RSAR1.LONG = (unsigned long)src;
166
167 /* ----Setting DMA destination address register---- */
168 DMAC.DAR1.LONG = (unsigned long)dst;
169
170 /* ----Setting DMA reload destination address register---- */
171 DMAC.RDAR1.LONG = (unsigned long)dst;
172
173 /* ----Setting DMA transfer count register---- */
174 /* ----Setting DMA reload transfer count register---- */
175
176 switch(ts){
177 case DMA_SIZE_BYTE:
178 DMAC.DMATCR0.LONG = size; /*
Specify transfer count (1/1) */
179 DMAC.RDMATCR0.LONG = size;
180 break;
181 case DMA_SIZE_WORD:
182 DMAC.DMATCR0.LONG = size >> 1u; /* Specify transfer count (1/2) */
183 DMAC.RDMATCR0.LONG = size >> 1u;
184 break;
185 case DMA_SIZE_LONG:
186 DMAC.DMATCR0.LONG = size >> 2u; /* Specify transfer count (1/4) */
187 DMAC.RDMATCR0.LONG = size >> 2u;
188 break;
189 case DMA_SIZE_LONGx4:
190 DMAC.DMATCR0.LONG = size >> 4u; /* Specify transfer count (1/16) */
191 DMAC.RDMATCR0.LONG = size >> 4u;
192 break;
193 default:
194 break;
195 }
196
197 /* ----Setting DMA channel control register---- */
198 DMAC.CHCR1.LONG = 0x00001800ul | (ts << 3u) | (ie << 2u) ;
199 /*
200 bit31 : TC DMATCR transfer0--------- Transfer once
201 bit30 : reserve 0
202 bit29 : RLDSAR OFF : 0------------- Disable SAR reload function
203 bit28 : RLDDAR OFF : 0------------- Disable DAR reload function
204 bit27-24 : reserve 0
205 bit23 : DO over run0 : 0---------- Unused
206 bit22 : TL TEND low active : 0---- Unused
207 bit21 : reserve 0
208 bit20 : TEMASK : TE set mask : 0-- Disable DMA transfer when TE bit is set
209 bit19 : HE :0--------------------- Unused
210 bit18 : HIE :0-------------------- Unused
211 bit17 : AM :0--------------------- Unused
212 bit16 : AL :0--------------------- Unused
213 bit15-14 : DM1:0 DM0:0--------------- Fix destination address
214 bit13-12 : SM1:0 SM0:1--------------- Increment source address
215 bit11-8 : RS : auto request : B'1000- DMA extension resource selector
216 bit7 : DL : DREQ level : 0 ------- Unused