CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

pwm question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Marc
Guest







pwm question
PostPosted: Wed Jun 27, 2007 9:27 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jun 27, 2007 9:42 am     Reply with quote

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
PostPosted: Wed Jun 27, 2007 10:13 am     Reply with quote

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.
nilsener



Joined: 06 Dec 2005
Posts: 59

View user's profile Send private message

PostPosted: Wed Jun 27, 2007 10:48 am     Reply with quote

which PIC do you use?
Marc
Guest







PostPosted: Wed Jun 27, 2007 10:50 am     Reply with quote

18f4580
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group