This DMAChannel code works in Teensy 3.0 but not in LC, do somebody know why?
I'm trying to do more complex things with DMA and I got them working with Teensy 3.0, but I couldn't make it work with LC, so this is a sanity test basically..
Press 'p' to print the values in src and dst, at the beginning they are 10 and 5, respectively. Press 't' to trigger the DMA transfer from src to dst, not dst should be equal to src. Press 'p' to check.
In Teensy 3.0 it works (dst=src=10), but in Teensy LC nothing changes (the program doesn't crash, simply nothing gets moved around).
I'm trying to do more complex things with DMA and I got them working with Teensy 3.0, but I couldn't make it work with LC, so this is a sanity test basically..
Code:
#include "DMAChannel.h"
DMAChannel* dmaChannel = new DMAChannel();
volatile uint16_t src=10, dst=5;
char c=0;
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN, OUTPUT);
dmaChannel->source(src);
dmaChannel->destination(dst);
dmaChannel->transferSize(2);
dmaChannel->transferCount(1);
dmaChannel->interruptAtCompletion();
dmaChannel->enable();
dmaChannel->attachInterrupt(dma_isr);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()) {
c = Serial.read();
if(c=='t') { // trigger
Serial.println("triggerManual");
dmaChannel->triggerManual();
} else if(c=='p') { // trigger
Serial.print("src: ");
Serial.print(src);
Serial.print(", dst: ");
Serial.println(dst);
}
}
}
void dma_isr() {
digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN));
dmaChannel->clearInterrupt();
}
Press 'p' to print the values in src and dst, at the beginning they are 10 and 5, respectively. Press 't' to trigger the DMA transfer from src to dst, not dst should be equal to src. Press 'p' to check.
In Teensy 3.0 it works (dst=src=10), but in Teensy LC nothing changes (the program doesn't crash, simply nothing gets moved around).