2.8 DMA Driver

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.1 Module Documentation

2.8.1.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.1.1.1 Module description

Direct Memory Access driver to service high data throughput peripherals allowing them to access data memory directly using dsPIC MCUs.

Data structures
  • struct DMA_INTERFACE

    Structure containing the function pointers of DMA driver.

Functions
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.1.1.2 Function Documentation

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.

Parameters:
in channel

- Selected channel for the Callback handling

Returns:

none

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.

Parameters:
in callback

- Address of the callback function

Returns:

none

DMA_ChannelDisable()

static void DMA_ChannelDisable (enum DMA_CHANNEL channel)[inline], [static]

This inline function disables the DMA channel.

Precondition:

DMA_Initialize must be called.

Parameters:
in channel

- DMA channel number

Returns:

none

DMA_ChannelEnable()

static void DMA_ChannelEnable (enum DMA_CHANNEL channel)[inline], [static]

This inline function enables the DMA channel.

Precondition:

DMA_Initialize must be called

Parameters:
in channel

- DMA channel number

Returns:

none

DMA_ChannelTasks()

void DMA_ChannelTasks (void )

This function is used to implement the tasks for polled implementations of DMA Channel.

Precondition:

DMA_Initialize must be called

Parameters:
none
Returns:

none

DMA_Deinitialize()

void DMA_Deinitialize (void )

Deinitializes the DMA to POR values.

Parameters:
none
Returns:

none

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.

Precondition:

DMA_Initialize must be called

Parameters:
in channel

- DMA channel number

in address

- Destination address

Returns:

none

DMA_Initialize()

void DMA_Initialize (void )

Initializes the DMA module.

Parameters:
none
Returns:

none

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.

Precondition:

DMA_Initialize must be called

Parameters:
in channel

- DMA channel number

Returns:

true - DMA request is pending

false - DMA request is not pending

DMA_SoftwareTriggerEnable()

static void DMA_SoftwareTriggerEnable (enum DMA_CHANNEL channel)[inline], [static]

This inline function sets the software trigger of the DMA channel.

Precondition:

DMA_Initialize must be called

Parameters:
in channel

- DMA channel number

Returns:

none

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.

Precondition:

DMA_Initialize must be called

Parameters:
in channel

- DMA channel number

in address

- Source address

Returns:

none

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.

Precondition:

DMA_Initialize must be called

Parameters:
in channel

- DMA channel number

Returns:

Returns the transfer count value

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.

Precondition:

DMA_Initialize must be called

Parameters:
in channel

- DMA channel number

in transferCount

- Transfer count Value

Returns:

none

2.8.1.1.3 Enumeration Type Documentation

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.1.1.4 Variable Documentation

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.2 Class Documentation

2.8.2.1 DMA_INTERFACE Struct Reference

Structure containing the function pointers of DMA driver.

2.8.2.1.1 Detailed Description

Structure containing the function pointers of DMA driver.

#include <dma_interface.h>

Public Attributes

2.8.2.1.2 Member Data Documentation

The documentation for this struct was generated from the following file:

source/

dma_interface.h

ChannelCallbackRegister

void(* ChannelCallbackRegister) (void(*callback)(enum DMA_CHANNEL channel))

Pointer to DMA_ChannelCallbackRegister.

ChannelDisable

void(* ChannelDisable) (enum DMA_CHANNEL channel)

Pointer to DMA_ChannelDisable.

ChannelEnable

void(* ChannelEnable) (enum DMA_CHANNEL channel)

Pointer to DMA_ChannelEnable.

ChannelTasks

void(* ChannelTasks) (void)

Pointer to DMA_ChannelTasks (Supported only in polling mode)

DestinationAddressSet

void(* DestinationAddressSet) (enum DMA_CHANNEL channel, uint16_t address)

Pointer to DMA_DestinationAddressSet.

SourceAddressSet

void(* SourceAddressSet) (enum DMA_CHANNEL channel, uint16_t address)

Pointer to DMA_SourceAddressSet.

TransferCountGet

uint16_t(* TransferCountGet) (enum DMA_CHANNEL channel)

Pointer to DMA_TransferCountGet.

TransferCountSet

void(* TransferCountSet) (enum DMA_CHANNEL channel, uint16_t transferCount)

Pointer to DMA_TransferCountSet.

2.8.3 File Documentation

2.8.3.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.3.1.1 Functions

2.8.3.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.3.1.3 Detailed Description

This is the generated driver header file for the DMA driver.

DMA Generated Driver Header File

2.8.3.2 source/dma_interface.h File Reference

#include <stdint.h>
#include <stdbool.h>
#include "dma_types.h"

2.8.3.2.1 Data structures

  • struct DMA_INTERFACE

    Structure containing the function pointers of DMA driver.

2.8.3.2.2 Detailed Description

DMA Generated Driver Interface Header File

2.8.3.3 source/dma_types.h File Reference

This is the generated driver types header file for the DMA driver.

2.8.3.3.2 Detailed Description

This is the generated driver types header file for the DMA driver.

DMA Generated Driver Types Header File