5213 DMA caputre
Posted: Sun Apr 07, 2013 7:33 pm
Hi,
I'm trying to measure time intervals using the dma capture on the 5213.
I suspect I might have the vectors wrong on the interrupt. It doesn't go to the interrupt routine because i watch pin 23 with a scope.
INTERRUPT (TMR3_isr, 0x2700)
{
Pins[23]=1;//pulse to show we have been here
Pins[23]=0;
//static DWORD last_capture;
sim.timer[3].dter= 1; //clear the event flag
if ((sim.timer[3].dtmr & 0xc0) == 0x40) //captured rising edge?
{
// capture value is duration of low TMP03 output.
t2= sim.timer[3].dtcr;
}
else //captured falling edge... capture value is duration of high TMP03 output.
{
t1= sim.timer[3].dtcr;
}
t2l=t1l;
t1l=sim.timer[3].dtcr;
sim.timer[3].dtmr ^= 0xc0; //toggle edge bits so we detect other edge next
}
//I call this to set things up.
void init()
{
// initialize
Pins[21].function (PIN21_DTIN3);
Pins[23].function (PIN23_GPIO);
Pins[23].drive();
Pins[23]=0;
Pins[23]=1;
Pins[23]=0;
sim.timer[3].dtmr= 0x0043; //capture on rising edge, 1 prescaler, system clock / 1, enable timer, reset timer
sim.timer[3].dtxmr= 0; //no DMA request
// enable the interrupt controller
SetIntc ((long)TMR3_isr, 21/*TMR2 interrupt*/, 1, 7); //lowest priority on lowest interrupt level
}
Andy
I'm trying to measure time intervals using the dma capture on the 5213.
I suspect I might have the vectors wrong on the interrupt. It doesn't go to the interrupt routine because i watch pin 23 with a scope.
INTERRUPT (TMR3_isr, 0x2700)
{
Pins[23]=1;//pulse to show we have been here
Pins[23]=0;
//static DWORD last_capture;
sim.timer[3].dter= 1; //clear the event flag
if ((sim.timer[3].dtmr & 0xc0) == 0x40) //captured rising edge?
{
// capture value is duration of low TMP03 output.
t2= sim.timer[3].dtcr;
}
else //captured falling edge... capture value is duration of high TMP03 output.
{
t1= sim.timer[3].dtcr;
}
t2l=t1l;
t1l=sim.timer[3].dtcr;
sim.timer[3].dtmr ^= 0xc0; //toggle edge bits so we detect other edge next
}
//I call this to set things up.
void init()
{
// initialize
Pins[21].function (PIN21_DTIN3);
Pins[23].function (PIN23_GPIO);
Pins[23].drive();
Pins[23]=0;
Pins[23]=1;
Pins[23]=0;
sim.timer[3].dtmr= 0x0043; //capture on rising edge, 1 prescaler, system clock / 1, enable timer, reset timer
sim.timer[3].dtxmr= 0; //no DMA request
// enable the interrupt controller
SetIntc ((long)TMR3_isr, 21/*TMR2 interrupt*/, 1, 7); //lowest priority on lowest interrupt level
}
Andy