I am trying to transfer data over raw GPIO via DMA and have been unsuccessful. I don't want to use SPI or any other protocol. I have poured through the forums and still something is alluding me.
If I set myDMA1 to a destinationBuffer, the interrupt gets called but if I try to use the GPIO register it does not.
Code:
#include "DMAChannel.h"
DMAChannel myDMA1 = new DMAChannel();
DMAChannel myDMA2 = new DMAChannel();
unsigned char cbuf[6], c1 = 15;
unsigned char tbuf[6] = {1,2,3,4,5,6}, t1 = 20;
void p(void) {
unsigned int i;
Serial.print("c1=");
Serial.println(c1);
Serial.print("cbuf=");
for (i=0; i<sizeof(cbuf); i++) {
Serial.print(cbuf[i]);
Serial.print(", ");
}
Serial.print("\nt1=");
Serial.println(t1);
Serial.print("tbuf=");
for (i=0; i<sizeof(tbuf); i++) {
Serial.print(tbuf[i]);
Serial.print(", ");
}
Serial.println();
Serial.println();
}
void interrupt1(void) {
myDMA1.clearInterrupt();
Serial.println("Interrupt1 ");
}
void interrupt2(void) {
myDMA2.clearInterrupt();
Serial.println("Interrupt2 ");
}
void setup() {
pinMode(0, OUTPUT);
pinMode(2, INPUT);
while (!Serial) ;
delay(100);
Serial.println("DMA Test");
myDMA1.sourceBuffer(tbuf, sizeof(tbuf));
myDMA1.destination(CORE_PIN0_PINREG);
myDMA1.interruptAtCompletion();
myDMA1.transferCount(1);
myDMA1.attachInterrupt(interrupt1);
myDMA1.enable();
myDMA2.source(CORE_PIN2_PINREG);
myDMA2.destinationBuffer(cbuf, sizeof(cbuf));
myDMA2.interruptAtCompletion();
myDMA2.transferCount(1);
myDMA2.triggerAtHardwareEvent(CORE_PIN2_PINREG);
myDMA2.attachInterrupt(interrupt2);
myDMA2.enable();
delay(100);
myDMA1.triggerManual();
}
void loop() {
delay(1000);
p();
}
If I set myDMA1 to a destinationBuffer, the interrupt gets called but if I try to use the GPIO register it does not.