2.8 DMA Driver
2.8.1 Introduction
Overview
The Direct Memory Access (DMA) Controller is designed to service high-data-throughput peripherals operating on the SFR bus, allowing them to access data memory directly and eliminating the need for CPU-intensive management.
Features
- Multiple Independent and Independently-Programmable Channels.
- Four Programmable Transfer Modes.
- Byte or Word Support for Data Transfer.
- 16-Bit Source and Destination Address Register for Each Channel, Dynamically Updated and Reloadable.
- Upper and Lower Address Limit Registers.
2.8.2 Module Documentation
2.8.2.1 DMA Driver
Direct Memory Access driver to service high data throughput peripherals allowing them to access data memory directly using dsPIC MCUs.
2.8.2.1.1 Module description
Direct Memory Access driver to service high data throughput peripherals allowing them to access data memory directly using dsPIC MCUs.
2.8.2.1.1.1 Data structures
struct DMA_INTERFACE
Structure containing the function pointers of DMA driver.
2.8.2.1.1.2 Enumerations
enum DMA_CHANNEL { DMA_CHANNEL_0 = 0, DMA_CHANNEL_1 = 1, DMA_CHANNEL_2 = 2, DMA_CHANNEL_3 = 3, DMA_CHANNEL_4 = 4, DMA_CHANNEL_5 = 5, DMA_CHANNEL_6 = 6, DMA_CHANNEL_7 = 7, DMA_NUMBER_OF_CHANNELS = 8 }
Defines the DMA channles that are selected from the MCC Melody User Interface for the DMA transfers. The below are the custom names given in the MCC Melody User Interface.
2.8.2.1.1.3 Functions
void DMA_Initialize (void)
Initializes the DMA module.
void DMA_Deinitialize (void)
Deinitializes the DMA to POR values.
static void DMA_ChannelEnable (enum DMA_CHANNEL channel)
This inline function enables the DMA channel.
static void DMA_ChannelDisable (enum DMA_CHANNEL channel)
This inline function disables the DMA channel.
static void DMA_TransferCountSet (enum DMA_CHANNEL channel, uint16_t transferCount)
This inline function sets the number of transfer counts to DMA channel.
static uint16_t DMA_TransferCountGet (enum DMA_CHANNEL channel)
This inline function returns the number of transfer counts from DMA channel.
static void DMA_SoftwareTriggerEnable (enum DMA_CHANNEL channel)
This inline function sets the software trigger of the DMA channel.
static void DMA_SourceAddressSet (enum DMA_CHANNEL channel, uint16_t address)
This inline function sets the source address to specified DMA channel.
static void DMA_DestinationAddressSet (enum DMA_CHANNEL channel, uint16_t address)
This inline function sets the destination address to specified DMA channel.
static bool DMA_IsSoftwareRequestPending (enum DMA_CHANNEL channel)
This inline function returns the status of the software request of the DMA channel.
void DMA_ChannelTasks (void)
This function is used to implement the tasks for polled implementations of DMA Channel.
void DMA_ChannelCallbackRegister (void(*callback)(enum DMA_CHANNEL channel))
This function can be used to override default callback and to define custom callback for DMA Channel event.
void DMA_ChannelCallback (enum DMA_CHANNEL channel)
This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using DMA_ChannelCallbackRegister.
2.8.2.1.1.4 Variables
const struct DMA_INTERFACE DMA
Structure object of type DMA_INTERFACE with the custom name given by the user in the Melody Driver User interface.
2.8.2.1.2 Function Documentation
2.8.2.1.2.1 DMA_ChannelCallback()
void DMA_ChannelCallback (enum DMA_CHANNEL channel)
This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using DMA_ChannelCallbackRegister.
in | channel |
- Selected channel for the Callback handling |
none |
2.8.2.1.2.2 DMA_ChannelCallbackRegister()
void DMA_ChannelCallbackRegister (void(*)(enum DMA_CHANNEL channel) callback)
This function can be used to override default callback and to define custom callback for DMA Channel event.
in | callback |
- Address of the callback function |
none |
2.8.2.1.2.3 DMA_ChannelDisable()
static void DMA_ChannelDisable (enum DMA_CHANNEL channel)[inline], [static]
This inline function disables the DMA channel.
DMA_Initialize must be called. |
in | channel |
- DMA channel number |
none |
2.8.2.1.2.4 DMA_ChannelEnable()
static void DMA_ChannelEnable (enum DMA_CHANNEL channel)[inline], [static]
This inline function enables the DMA channel.
DMA_Initialize must be called |
in | channel |
- DMA channel number |
none |
2.8.2.1.2.5 DMA_ChannelTasks()
void DMA_ChannelTasks (void )
This function is used to implement the tasks for polled implementations of DMA Channel.
DMA_Initialize must be called |
none |
none |
2.8.2.1.2.6 DMA_Deinitialize()
void DMA_Deinitialize (void )
Deinitializes the DMA to POR values.
none |
none |
2.8.2.1.2.7 DMA_DestinationAddressSet()
static void DMA_DestinationAddressSet (enum DMA_CHANNEL channel, uint16_t address)[inline], [static]
This inline function sets the destination address to specified DMA channel.
DMA_Initialize must be called |
in | channel |
- DMA channel number |
in | address |
- Destination address |
none |
2.8.2.1.2.8 DMA_Initialize()
void DMA_Initialize (void )
Initializes the DMA module.
none |
none |
2.8.2.1.2.9 DMA_IsSoftwareRequestPending()
static bool DMA_IsSoftwareRequestPending (enum DMA_CHANNEL channel)[inline], [static]
This inline function returns the status of the software request of the DMA channel.
DMA_Initialize must be called |
in | channel |
- DMA channel number |
true - DMA request is pending false - DMA request is not pending |
2.8.2.1.2.10 DMA_SoftwareTriggerEnable()
static void DMA_SoftwareTriggerEnable (enum DMA_CHANNEL channel)[inline], [static]
This inline function sets the software trigger of the DMA channel.
DMA_Initialize must be called |
in | channel |
- DMA channel number |
none |
2.8.2.1.2.11 DMA_SourceAddressSet()
static void DMA_SourceAddressSet (enum DMA_CHANNEL channel, uint16_t address)[inline], [static]
This inline function sets the source address to specified DMA channel.
DMA_Initialize must be called |
in | channel |
- DMA channel number |
in | address |
- Source address |
none |
2.8.2.1.2.12 DMA_TransferCountGet()
static uint16_t DMA_TransferCountGet (enum DMA_CHANNEL channel)[inline], [static]
This inline function returns the number of transfer counts from DMA channel.
DMA_Initialize must be called |
in | channel |
- DMA channel number |
Returns the transfer count value |
2.8.2.1.2.13 DMA_TransferCountSet()
static void DMA_TransferCountSet (enum DMA_CHANNEL channel, uint16_t transferCount)[inline], [static]
This inline function sets the number of transfer counts to DMA channel.
DMA_Initialize must be called |
in | channel |
- DMA channel number |
in | transferCount |
- Transfer count Value |
none |
2.8.2.1.3 Enumeration Type Documentation
2.8.2.1.3.1 DMA_CHANNEL
enum DMA_CHANNEL
Defines the DMA channles that are selected from the MCC Melody User Interface for the DMA transfers. The below are the custom names given in the MCC Melody User Interface.
DMA_CHANNEL_0 |
DMA channel 0 |
DMA_CHANNEL_1 |
DMA channel 1 |
DMA_CHANNEL_2 |
DMA channel 2 |
DMA_CHANNEL_3 |
DMA channel 3 |
DMA_CHANNEL_4 |
DMA channel 4 |
DMA_CHANNEL_5 |
DMA channel 5 |
DMA_CHANNEL_6 |
DMA channel 6 |
DMA_CHANNEL_7 |
DMA channel 7 |
DMA_NUMBER_OF_CHANNELS |
Maximum number of Channels supported by hardware : 8 |
2.8.2.1.4 Variable Documentation
2.8.2.1.4.1 DMA
const struct DMA_INTERFACE DMA
Structure object of type DMA_INTERFACE with the custom name given by the user in the Melody Driver User interface.
The default name e.g. DMA can be changed by the user in the DMA user interface. This allows defining a structure with application specific name using the 'Custom Name' field. Application specific name allows the API Portability.
2.8.3 Class Documentation
2.8.3.1 DMA_INTERFACE Struct Reference
Structure containing the function pointers of DMA driver.
2.8.3.1.1 Detailed Description
Structure containing the function pointers of DMA driver.
#include <dma_interface.h>
2.8.3.1.1.1 Public Attributes
void(* Initialize )(void)
Pointer to DMA_Initialize.
void(* Deinitialize )(void)
Pointer to DMA_Deinitialize.
void(* ChannelEnable )(enum DMA_CHANNEL channel)
Pointer to DMA_ChannelEnable.
void(* ChannelDisable )(enum DMA_CHANNEL channel)
Pointer to DMA_ChannelDisable.
void(* TransferCountSet )(enum DMA_CHANNEL channel, uint16_t transferCount)
Pointer to DMA_TransferCountSet.
uint16_t(* TransferCountGet )(enum DMA_CHANNEL channel)
Pointer to DMA_TransferCountGet.
void(* SoftwareTriggerEnable )(enum DMA_CHANNEL channel)
Pointer to DMA_SoftwareTriggerEnable.
void(* SourceAddressSet )(enum DMA_CHANNEL channel, uint16_t address)
Pointer to DMA_SourceAddressSet.
void(* DestinationAddressSet )(enum DMA_CHANNEL channel, uint16_t address)
Pointer to DMA_DestinationAddressSet.
bool(* IsSoftwareRequestPending )(enum DMA_CHANNEL channel)
Pointer to DMA_IsSoftwareRequestPending.
void(* ChannelCallbackRegister )(void(*callback)(enum DMA_CHANNEL channel))
Pointer to DMA_ChannelCallbackRegister.
void(* ChannelTasks )(void)
Pointer to DMA_ChannelTasks (Supported only in polling mode)
2.8.3.1.2 Member Data Documentation
2.8.3.1.2.1 ChannelCallbackRegister
void(* ChannelCallbackRegister) (void(*callback)(enum DMA_CHANNEL channel))
Pointer to DMA_ChannelCallbackRegister.
2.8.3.1.2.2 ChannelDisable
void(* ChannelDisable) (enum DMA_CHANNEL channel)
Pointer to DMA_ChannelDisable.
2.8.3.1.2.3 ChannelEnable
void(* ChannelEnable) (enum DMA_CHANNEL channel)
Pointer to DMA_ChannelEnable.
2.8.3.1.2.4 ChannelTasks
void(* ChannelTasks) (void)
Pointer to DMA_ChannelTasks (Supported only in polling mode)
2.8.3.1.2.5 Deinitialize
void(* Deinitialize) (void)
Pointer to DMA_Deinitialize.
2.8.3.1.2.6 DestinationAddressSet
void(* DestinationAddressSet) (enum DMA_CHANNEL channel, uint16_t address)
Pointer to DMA_DestinationAddressSet.
2.8.3.1.2.7 Initialize
void(* Initialize) (void)
Pointer to DMA_Initialize.
2.8.3.1.2.8 IsSoftwareRequestPending
bool(* IsSoftwareRequestPending) (enum DMA_CHANNEL channel)
Pointer to DMA_IsSoftwareRequestPending.
2.8.3.1.2.9 SoftwareTriggerEnable
void(* SoftwareTriggerEnable) (enum DMA_CHANNEL channel)
Pointer to DMA_SoftwareTriggerEnable.
2.8.3.1.2.10 SourceAddressSet
void(* SourceAddressSet) (enum DMA_CHANNEL channel, uint16_t address)
Pointer to DMA_SourceAddressSet.
2.8.3.1.2.11 TransferCountGet
uint16_t(* TransferCountGet) (enum DMA_CHANNEL channel)
Pointer to DMA_TransferCountGet.
2.8.3.1.2.12 TransferCountSet
void(* TransferCountSet) (enum DMA_CHANNEL channel, uint16_t transferCount)
Pointer to DMA_TransferCountSet.
2.8.4 File Documentation
2.8.4.1 source/dma.h File Reference
This is the generated driver header file for the DMA driver.
#include <xc.h> #include <stdbool.h> #include <stdint.h> #include "dma_types.h" #include "dma_interface.h"
2.8.4.1.1 Functions
void DMA_Initialize (void)
Initializes the DMA module.
void DMA_Deinitialize (void)
Deinitializes the DMA to POR values.
static void DMA_ChannelEnable (enum DMA_CHANNEL channel)
This inline function enables the DMA channel.
static void DMA_ChannelDisable (enum DMA_CHANNEL channel)
This inline function disables the DMA channel.
static void DMA_TransferCountSet (enum DMA_CHANNEL channel, uint16_t transferCount)
This inline function sets the number of transfer counts to DMA channel.
static uint16_t DMA_TransferCountGet (enum DMA_CHANNEL channel)
This inline function returns the number of transfer counts from DMA channel.
static void DMA_SoftwareTriggerEnable (enum DMA_CHANNEL channel)
This inline function sets the software trigger of the DMA channel.
static void DMA_SourceAddressSet (enum DMA_CHANNEL channel, uint16_t address)
This inline function sets the source address to specified DMA channel.
static void DMA_DestinationAddressSet (enum DMA_CHANNEL channel, uint16_t address)
This inline function sets the destination address to specified DMA channel.
static bool DMA_IsSoftwareRequestPending (enum DMA_CHANNEL channel)
This inline function returns the status of the software request of the DMA channel.
void DMA_ChannelTasks (void)
This function is used to implement the tasks for polled implementations of DMA Channel.
void DMA_ChannelCallbackRegister (void(*callback)(enum DMA_CHANNEL channel))
This function can be used to override default callback and to define custom callback for DMA Channel event.
void DMA_ChannelCallback (enum DMA_CHANNEL channel)
This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using DMA_ChannelCallbackRegister.
2.8.4.1.2 Variables
const struct DMA_INTERFACE DMA
Structure object of type DMA_INTERFACE with the custom name given by the user in the Melody Driver User interface.
2.8.4.1.3 Detailed Description
This is the generated driver header file for the DMA driver.
DMA Generated Driver Header File
2.8.4.2 source/dma_interface.h File Reference
#include <stdint.h> #include <stdbool.h> #include "dma_types.h"
2.8.4.2.1 Data structures
struct DMA_INTERFACE
Structure containing the function pointers of DMA driver.
2.8.4.2.2 Detailed Description
DMA Generated Driver Interface Header File
2.8.4.3 source/dma_types.h File Reference
This is the generated driver types header file for the DMA driver.
2.8.4.3.1 Enumerations
enum DMA_CHANNEL { DMA_CHANNEL_0 = 0, DMA_CHANNEL_1 = 1, DMA_CHANNEL_2 = 2, DMA_CHANNEL_3 = 3, DMA_CHANNEL_4 = 4, DMA_CHANNEL_5 = 5, DMA_CHANNEL_6 = 6, DMA_CHANNEL_7 = 7, DMA_NUMBER_OF_CHANNELS = 8 }
Defines the DMA channles that are selected from the MCC Melody User Interface for the DMA transfers. The below are the custom names given in the MCC Melody User Interface.
2.8.4.3.2 Detailed Description
This is the generated driver types header file for the DMA driver.
DMA Generated Driver Types Header File