Charles Cudjoe

Capture module in code warrior 8

Discussion created by Charles Cudjoe on Nov 10, 2008
Latest reply on Nov 14, 2008 by Pascal Irrle

Hi everyone. Here's my problem. I have zero crossing detector circuit that sends a 50Hz PWM to my timer D capture module (DSP56f807). I am using the timer1 pin as the input pin. I want to detect this PWM on the rising edge and this will start a timer. On the second rising edge the timer must stop. I want to retrieve this value and use it to determine the period of the signal. I used the following code in my interrupt service routine to do this:

void Cap1_OnCapture(void)
{
  /* Write your code here ... */
if(u==2)
{
Cap1_DisableEvent();
/
Cap1_GetCaptureValue(&SAMPLES_Current[t]);

if(t==MAXSAMPLES)
{
for(p=20;p<40;p++)   
printf("ms - %u\n" , SAMPLES_Current[p]);
}
   

u=0;   
if(t<MAXSAMPLES)
t++;
else
t==0;
Cap1_Reset();

}




else u++;

}

I just used the printf to test if it was capturing the time. My problem is the value it reads isn't constant even though the input PWM is constant. Please help!!!! I have included my code.

 

eaw_code.zip

Message Edited by t.dowe on 2009-10-15 05:59 PM

Outcomes