1.35.5 1.36.8 Memory to Memory (MEM2MEM)
The Memory to Memory (MEM2MEM) module allows the Peripheral DMA Controller (PDC) to perform memory to memory transfer without CPU intervention. The transfer size can be configured in byte, half-word or word. Two PDC channels are required to perform the transfer; one channel defines the source of the transfer and the other defines the destination.
Using The Library
This library used PDC to transfer data from memory to memory without CPU intervention.
// Transfer 10 bytes of data from one buffer to another using MEM2MEM MY_APP_OBJ myAppObj; uint8_t buf[10] = {0,1,2,3,4,5,6,7,8,9}; uint8_t buf2[10] = {}; void *srcAddr = (uint8_t *) buf; void *destAddr = (uin8_t*) buf2; size_t size = 10; // User registers an event handler with PLIB. This is done once. MEM2MEM_ChannelCallbackRegister(APP_MEM2MEMTransferEventHandler, (uintptr_t)&myAppObj); if(MEM2MEM_ChannelTransfer(srcAddr, destAddr, size,MEM2MEM_TRANSFER_WIDTH_BYTE) == true) { // do something } else { // try again? }
Library Interface
Memory to Memory peripheral library provides the following interfaces:
Functions
Name | Description |
---|---|
MEM2MEM_ChannelCallbackRegister | This function allows a MEM2MEM PLIB client to set a callback |
MEM2MEM_ChannelTransfer | Registers a DMA transfer using MEM2MEM |
Data types and constants
Name | Type | Description |
---|---|---|
MEM2MEM_TRANSFER_WIDTH | Enum | Identifies the transfer width to be used |
MEM2MEM_TRANSFER_EVENT | Enum | Enumeration of possible MEM2MEM transfer events |
MEM2MEM_CALLBACK | Typedef | Pointer to a MEM2MEM Transfer Event handler function |