//--------------------------------------------------------------------------- // L361.C // Using the 80C188XL internal DMA channel 0 for implementing a // Memory to Memory tansfer, i.e., copy one string to another. // Unsynchonized transfer terminates without interrupt generation. // // C/C++ code for the SBC188 board. // C.P. Diduch, March 1999. //--------------------------------------------------------------------------- #define TRUE 1 #define D0SRCL 0xFFC0 // 80C188 DMA0 SRC address: lo 16-bits. #define D0SRCH 0xFFC2 // 80C188 DMA0 SRC address: hi 4-bits. #define D0DSTL 0xFFC4 // 80C188 DMA0 DST address: lo 16-bits. #define D0DSTH 0xFFC6 // 80C188 DMA0 DST address: hi 4-bits. #define D0TC 0xFFC8 // 80C188 DMA0 terminal count register. #define D0CON 0xFFCA // 80C188 DMA0 control register. #include #include void delay(unsigned MILLISECS); // Function prototypes. void dma_mem_mem(char *x, char *y, unsigned z, unsigned NO_BYTES); //--------------------------------------------------------------------------- void main(void) { char DATA[] = {1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3, \ 4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6}; char BUFF[60]; unsigned SA; asm{ mov SA, ds // Get segment address of BUFF[] and DATA[]. } // Initialize and arm DMA0 to transfer 60 bytes from array DATA[] // to array BUFF[]. dma_mem_mem(&BUFF[0], &DATA[0], SA, 60); delay(1000); } //--------------------------------------------------------------------------- void dma_mem_mem(char *DST, char *SRC, unsigned SA, unsigned NO_BYTES) { long PA; unsigned LO, HI; PA = (16* (long) SA) + (unsigned) SRC; LO = (unsigned) PA; HI = (unsigned) (PA >> 16); outport(D0SRCL, LO); outport(D0SRCH, HI); PA = (16* (long) SA) + (unsigned) DST; LO = (unsigned) PA; HI = (unsigned) (PA >> 16); outport(D0DSTL, LO); outport(D0DSTH, HI); outport(D0TC, NO_BYTES); // with interrupt. outport(D0CON, 0xB606); // Unsynchronize transfer terminates // with NO interrupt } //--------------------------------------------------------------------------- void delay(unsigned MILLISECS) { unsigned M; while (MILLISECS != 0) { M = 1000; while (M != 0) {M--;} MILLISECS--; } }