8.6 Bit-Reversed and Modulo Addressing

Bit-reversed and modulo addressing is supported on all dsPIC DSC devices.

Bit-reversed addressing is used for simplifying and speeding-up the writes to X-space data arrays in FFT (Fast Fourier Transform) algorithms. When enabled, pre-increment or post-increment addressing modes will reverse the lower order address bits used by instructions.

Modulo, or circular addressing, provides an automated means to support circular data buffers using the dsPIC hardware. When used, software no longer needs to perform data address boundary checks on arrays.

The compiler does not directly support the use of bit-reversed and modulo addressing; that is, it cannot generate code from C source that assumes these addressing modes are enabled when accessing memory. If either of these addressing modes are set up on the target device, then it is the programmer’s responsibility to ensure that the compiler does not use those registers that are specified to use either modulo or bit-reversed addressing as pointers. Particular care must be exercised if interrupts can occur while one of these addressing modes is enabled.

It is possible to define arrays in C that will be suitably aligned in memory for modulo addressing by hand-written assembly language functions. The aligned attribute may be used to define arrays that are positioned for use as incrementing modulo buffers. Initialization of the start and end addresses, as well as the registers that modulo address is applied must be written by hand to match the array specification. The reverse attribute may be used to define arrays that are positioned for use as decrementing modulo buffers. For more information on these attributes, see the Function Specifiers section. For more information on bit-reversed or modulo addressing, see your device Family Reference Manual (FRM).