User Functions; Alternate Implementation - Atmel AT91 Series Application Note

Arm thumb microcontrollers
Hide thumbs Also See for AT91 Series:
Table of Contents

Advertisement

User Functions

The functions used to manage the DMA Turbo are defined in dma_turb.c :
Table 3. DMA Turbo User Functions
void DmaTurboSet (int *source, int *destination)
void DmaTurboGet (int *source, int size)
void DmaTurboFiq (void)
The DmaTurboSet function initializes the FIQ banked registers for the DMA Turbo transfer, then enables the DMA transfer
by clearing bit F in the CPSR.
void DmaTurboSet (int *source, int *destination)
source
destination the destination buffer pointer
Begin
| Switch to FIQ mode and save entry mode
| Memorize source buffer pointer (r12_fiq = 'src_pt')
| Memorize destination buffer pointer (r13_fiq = 'dest_pt')
| Enable DMA (Clear bit F)
| Restore entry mode
End
The DmaTurboGet function checks that the end of the transfer occurred ("size" words received), and, if it did, disables the
DMA transfer by setting bit F in the CPSR.
int DmaTurboGet (int * source, int size) returns the number of words already received
source
size
Begin
| Switch to FIQ mode and save entry mode
| Calculate number of transferred words
| Disable DMA (Clear bit F) if number of transferred words >= size
| Restore entry mode
End
The DmaTurboFiq function is activated by the FIQ (vector address 0x1C), and copies 4 words from source buffer to desti-
nation buffer.
void DmaTurboFiq (void)
Begin
| *dest_pt <- *src_pt (multiple load and store 4 words with post increment)
End

Alternate Implementation

The DMA Turbo can be modified to transfer more than 4 words per FIQ. For this, the pair of instructions "ldm" and "stm"
(refer to the "ARM Architectural Reference Manual") must be repeated as many times as necessary. Different types of
source and destination buffers can be supported by using the options of post/pre increment/decrement of these instruc-
tions.
It can also be modified to make the number of words to transfer defined by the caller. This has the advantage of allowing
the dynamic transfer size, but one register must be reserved for the count (e.g. r11). Therefore, only 3 registers are avail-
able for the transfer itself.
Initialize the FIQ registers for the DMA transfer
Check the end of the transfer
FIQ treatment and DMA transfer
the source buffer pointer
the source buffer pointer at beginning
the number of words to be copied
AT91 Series
3

Advertisement

Table of Contents
loading

Table of Contents