English
Language : 

C8051F970-A-GM Datasheet, PDF (212/454 Pages) Silicon Laboratories – Low Power Capacitive Sensing MCU with up to 32 kB of Flash
C8051F97x
22.11.3. Initializing Memory Block Using DMA0 and MAC0
This example demonstrates a sophisticated example of initializing a block of memory in XRAM with value 0x55.
// Memory block to initialize
volatile SEGMENT_VARIABLE(memblock[500], U8, SEG_XDATA);
SFRPAGE = DMA0_PAGE; // Change Page register to DMA0 Page
DMA0SEL = 0;
// Select DMA channel 0
DMA0EN &= ~0x01;
// Disable DMA channel 0
DMA0INT &= ~0x01;
// Clear interrupt bit for channel 0
DMA0NCF = 0x05;
// Select MAC0 Accumulator to XRAM transfer
DMA0NCF |= (LSB << 4); // Use LSB to spec endian bit for compiler independence
DMA0NBA = (U16)&memblock[0]; // XRAM base address
DMA0NAO = 0;
// XRAM offset
DMA0NSZ = 500;
// Transfer 500 bytes
DMA0EN |= 0x01;
// Enable DMA channel 0
// No need to change page register as MAC0 and DMA0 registers are in same page.
MAC0CF0 = 0x28;
// Clear accumulator, Multiply Only mode
MAC0CF1 = 0x0a;
// Select unsigned mode, constant A and constant B
MAC0CF2 = 0x04;
// Disable rounding, saturation and alignment logic
// 2-byte DMA transaction from MAC0 Accumulator to XRAM
MAC0A = 1;
// Load MAC0A with 1 decimal
MAC0B = 0x5555;
// Load MAC0B with 0x5555 hexadecimal
MAC0ICT = 1;
// Set to 1 iteration
MAC0STA = 1;
// Set BUSY to start MAC operation
while (!(DMA0INT & 1)); // Poll for DMA Channel 0 completion interrupt
// All 500 bytes in memblock[] will be initialized to 0x55
Rev 1.0
213