DM5SG
Member
iam trying to get TMR4 to work as trigger source for dma transfer. i spend quiete some time so far but but no result as expacted.
interrupts are fired at a constant rate but arnt as predicted. changing samp_timer value or even TMR_CTRL_PCS(x) x=8..15 dosent effect the interupt rate.
i have scrached my head of but cant find the reason. even routing the timer output through XBAR to edge trigger DMA request dosent make a difference
#include <Arduino.h>
#include <DMAChannel.h>
#define buffer_len 128
#define sfreq 44100
#define samp_timer F_BUS_ACTUAL / sfreq
DMAChannel dma;
DMAMEM static volatile __attribute__((aligned(32))) int tx_buffer[buffer_len];
int volatile cnt = 0;
void myisr()
{
dma.clearInterrupt();
if (cnt++ > sfreq)
{
cnt = 0;
digitalToggle(LED_BUILTIN);
}
}
void setup()
{
// place test values
for (int x = 0; x < buffer_len; x++)
tx_buffer[x] = 10000 + x * 25;
//QuadTimer 4 channel 3
TMR4_ENBL &= ~(1 << 3); //Disable
TMR4_SCTRL3 = 0;
TMR4_LOAD3 = 0;
TMR4_CNTR3 = 0;
TMR4_COMP13 = samp_timer;
TMR4_CMPLD13 = samp_timer;
TMR4_DMA3 = TMR_DMA_CMPLD1DE;
TMR4_CSCTRL3 = TMR_CSCTRL_CL1(1);
TMR4_CTRL3 = TMR_CTRL_CM(1) | TMR_CTRL_PCS(8) | TMR_CTRL_LENGTH;
TMR4_ENBL |= (1 << 3); //Enable
dma.sourceBuffer(tx_buffer, sizeof(tx_buffer));
dma.destination(CCM_ANALOG_PLL_VIDEO_NUM);
dma.triggerAtHardwareEvent(DMAMUX_SOURCE_QTIMER4_WRITE3_CMPLD1);
dma.interruptAtHalf();
dma.interruptAtCompletion();
dma.attachInterrupt(myisr);
dma.enable();
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
}
interrupts are fired at a constant rate but arnt as predicted. changing samp_timer value or even TMR_CTRL_PCS(x) x=8..15 dosent effect the interupt rate.
i have scrached my head of but cant find the reason. even routing the timer output through XBAR to edge trigger DMA request dosent make a difference
#include <Arduino.h>
#include <DMAChannel.h>
#define buffer_len 128
#define sfreq 44100
#define samp_timer F_BUS_ACTUAL / sfreq
DMAChannel dma;
DMAMEM static volatile __attribute__((aligned(32))) int tx_buffer[buffer_len];
int volatile cnt = 0;
void myisr()
{
dma.clearInterrupt();
if (cnt++ > sfreq)
{
cnt = 0;
digitalToggle(LED_BUILTIN);
}
}
void setup()
{
// place test values
for (int x = 0; x < buffer_len; x++)
tx_buffer[x] = 10000 + x * 25;
//QuadTimer 4 channel 3
TMR4_ENBL &= ~(1 << 3); //Disable
TMR4_SCTRL3 = 0;
TMR4_LOAD3 = 0;
TMR4_CNTR3 = 0;
TMR4_COMP13 = samp_timer;
TMR4_CMPLD13 = samp_timer;
TMR4_DMA3 = TMR_DMA_CMPLD1DE;
TMR4_CSCTRL3 = TMR_CSCTRL_CL1(1);
TMR4_CTRL3 = TMR_CTRL_CM(1) | TMR_CTRL_PCS(8) | TMR_CTRL_LENGTH;
TMR4_ENBL |= (1 << 3); //Enable
dma.sourceBuffer(tx_buffer, sizeof(tx_buffer));
dma.destination(CCM_ANALOG_PLL_VIDEO_NUM);
dma.triggerAtHardwareEvent(DMAMUX_SOURCE_QTIMER4_WRITE3_CMPLD1);
dma.interruptAtHalf();
dma.interruptAtCompletion();
dma.attachInterrupt(myisr);
dma.enable();
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
}