T4 DMA Buffer of data to a pin as serial data.

Status
Not open for further replies.

JoeG99

New member
I am trying to use DMA on the T4 to output a buffer of data on an pin. Similar to what the WS2812Serial did on the T3. Is there some guidance for this sort of DMA output?
 
I would like to be able to do something like

uint32_t myBuffer[352];
//Define the pin we will use for output
int myPin = 22;
int Location = 10;
myDMA = new DMAChannel();
myDMA.disable();
myDMA.attachInterrupt(UpdateLocation);
myDMA.interruptAtCompletion();
//output 23 bytes of the buffer starting at Location
myDMA.sourceBuffer((uint8_t *)myBuffer[Location],23);
//output data serially on myPin
myDMA.destination(myPin );
// set 8 cycle wait between output bits
myDMA.TCD->BWC = 11b;
myDMA.transferSize(1);
myDMA.disableOnCompletion();
myDMA.triggerContinuously();
myDMA.enable();

void UpdateLocation(void){
//logic that updates the location to a different spot in the buffer
Location += 18;
myDMA.disable();
myDMA.sourceBuffer((uint8_t *)myBuffer[Location], 23);
myDMA.enable();

}

void loop() {
//do some stuff
if (condition) { myDMA.start(); }
//do other stuff
}
 
Status
Not open for further replies.
Back
Top