#pragma bitfields=reversed *******************************88
typedef struct {
BYTE SRCADDRH;
BYTE SRCADDRL;
BYTE DESTADDRH;
BYTE DESTADDRL;
BYTE VLEN : 3;
BYTE LENH : 5;
BYTE LENL : 8;
BYTE WORDSIZE : 1;
BYTE TMODE : 2;
BYTE TRIG : 5;
BYTE SRCINC : 2;
BYTE DESTINC : 2;
BYTE IRQMASK : 1;
BYTE M8 : 1;
BYTE PRIORITY : 2;
} DMA_DESC;
#pragma bitfields=default
//写一个函数,使数据通过DMA传到另外一个数组里
void use_dma_one(void)
{
DMA_DESC dmaChannel;
BYTE sourceString[16] = "SHENZHEN WXL";
//sourceString[0] = 0;
//sourceString[1] = 7;
BYTE destString[14];
memset(destString,0,14);
SET_WORD(dmaChannel.SRCADDRH, dmaChannel.SRCADDRL, &sourceString); // The start address of the data to be transmitted
SET_WORD(dmaChannel.DESTADDRH, dmaChannel.DESTADDRL, &destString); // The start address of the destination.
SET_WORD(dmaChannel.LENH, dmaChannel.LENL, 12); // Setting the number of bytes to transfer.
//dmaChannel.VLEN = VLEN_USE_LEN; // Using the length field to determine how many bytes to transfer.
dmaChannel.VLEN = VLEN_USE_LEN;
dmaChannel.PRIORITY = PRI_HIGH; // High priority.
dmaChannel.M8 = M8_USE_8_BITS; // Irrelevant since length is determined by the LENH and LENL.
dmaChannel.IRQMASK = FALSE; // The DMA shall not issue an IRQ upon completion.
dmaChannel.DESTINC = DESTINC_1; // The destination address is to be incremented by 1 after each transfer.
dmaChannel.SRCINC = SRCINC_1; // The source address inremented by 1 byte after each transfer.
dmaChannel.TRIG = DMATRIG_NONE; // The DMA channel will be started manually.
dmaChannel.TMODE = TMODE_BLOCK; // The number of bytes specified by LENH and LENL is transferred.
dmaChannel.WORDSIZE = WORDSIZE_BYTE; // One byte is transferred each time.
DMA_SET_ADDR_DESC0(&dmaChannel);
DMA_ABORT_CHANNEL(0);
DMA_ARM_CHANNEL(0);
halWait(10);
DMAIRQ = 0x00;
DMA_START_CHANNEL(0);
while( !(DMAIRQ & DMA_CHANNEL_0) );
halWait(10);
}