Page 1 of 1

5213 DMA caputre

Posted: Sun Apr 07, 2013 7:33 pm
by ahbushnell
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

Re: 5213 DMA caputre

Posted: Sun Apr 07, 2013 7:57 pm
by ahbushnell
Opps. As soon as a posted this I looked at the code and saw the mistake.

I had the vector set to tmr2. It should be:

SetIntc ((long)TMR3_isr, 22/*TMR3 interrupt*/, 1, 7);

Andy