EasyManua.ls Logo

Microchip Technology dsPIC30F - Page 73

Microchip Technology dsPIC30F
738 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
© 2004 Microchip Technology Inc. DS70050C-page 3-13
Section 3. Data Memory
Data Memory
3
3.3.5 Modulo Addressing Initialization for Decrementing Modulo Buffer
The following steps describe the setup procedure for a decrementing circular buffer. The steps
are similar whether the X AGU or Y AGU is used.
1. Determine the buffer length in 16-bit data words. Multiply this value by 2 to get the length
of the buffer in bytes.
2. Select a buffer end address that is located at a binary ‘ones’ boundary, based on the
desired length of the buffer. Remember that the buffer length in words must be multiplied
by 2 to obtain the byte address range. For example, a buffer with a length of 128 words
(256 bytes) could use 0xXXFF as the end address.
3. Calculate the buffer start address using the buffer length chosen in Step 1 and the end
address chosen in Step 2. The buffer start address is calculated using Equation 3-2.
4. Load the XMODSRT (YMODSRT) register with the buffer start address chosen in Step 3.
5. Load the XMODEND (YMODEND) register with the buffer end address chosen in Step 2.
6. Write to the XWM<3:0> (YWM<3:0>) bits in the MODCON register to select the W register
that will be used to access the circular buffer.
7. Set the XMODEN (YMODEN) bit in the MODCON register to enable the circular buffer.
8. Load the selected W register with address that points to the buffer.
9. The W register address will be adjusted automatically at the end of the buffer when an
indirect access with pre/post-decrement is performed (see Figure 3-6).
Figure 3-6: Decrementing Buffer Modulo Addressing Operation Example
0x11E0
0x11FF
Start Addr = 0x11E0
End Addr = 0x11FF
Length = 16 Words
Byte
Address
MOV #0x11E0,W0
MOV W0,XMODSRT ;set modulo start address
MOV #0x11FF,W0
MOV W0,XMODEND ;set modulo end address
MOV #0x8001,W0
MOV W0,MODCON ;enable W1, X AGU for modulo
MOV #0x000F,W0 ;W0 holds buffer fill value
MOV #0x11FE,W1 ;point W1 to buffer
DO #15,FILL ;fill the 16 buffer locations
MOV W0,[W1--] ;fill the next location
FILL:
DEC W0,W0 ;decrement the fill value
; W1 = 0x11FE when DO loop completes

Table of Contents

Other manuals for Microchip Technology dsPIC30F