I have a circuit which drives a led: a pic micro generates a pwm signal to the gate of a mosfet connected source-drain to a led and a resistor in series. I try to measure with adc the led current at the resistor pins but I see pwm waveform.
Iask how to know when pic generates pwm signal equal to 1 and when equal to 0 so that I can turn on adc when pwm waveform is 1.
Thank You
nilsener
Joined: 06 Dec 2005 Posts: 59
Posted: Wed Jun 27, 2007 9:42 am
Dear Marc,
the PWM is controlled by Timer2. Try to read the ADC in the ISR of Timer2. There is a 50:50 chance that the PWM signal changes from L to H when the Timer2 interrupt occurs. If it changes from H to L then it will not work.
Code:
#int_timer2 // ISR for Timer 2
void T2_ISR(void)
{
delay_ms(1); // let LED current raise up
read_adc();
}// End T1_ISR()
Best Regards
Nilsener
Marc Guest
another question
Posted: Wed Jun 27, 2007 10:13 am
I do not know exactly how pics work but I think there should be a register in which it is written if pwm is 1 or 0 so that I can control that.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum