Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member Apr 17, 2013 #41 What c complier revision are you using? I have C18 3.40..
D drkidd22 Member Apr 17, 2013 #42 I'm using the same compiler. Did you modify the code I posted at all or did it work right of the bat?
I'm using the same compiler. Did you modify the code I posted at all or did it work right of the bat?
Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member Apr 17, 2013 #43 I had to insert my own LCD library... ( Oh I also used AN0 instead of AN7 )..
Angry Badger Member Apr 17, 2013 #44 Hi, I think this little snippet in the interrupt routine might be causing you grief: Code: if(Duty_cycle == 0) { PWM1_OUT = 0; } Try commenting it out and test the result.
Hi, I think this little snippet in the interrupt routine might be causing you grief: Code: if(Duty_cycle == 0) { PWM1_OUT = 0; } Try commenting it out and test the result.
Angry Badger Member Apr 17, 2013 #45 Hi, Try this as your interrupt routine: Code: #pragma interrupt ccpisr_hand void ccpisr_hand() { if(PIR1bits.CCP1IF == 1) if(PWM1_OUT == 1 ) //Will be 1 if we are at end of pulse { PWM1_OUT = 0; CCPR1 = 5000 - temp; //Off time } else { if(Duty_cycle > 0 && Duty_cycle < 97) { PWM1_OUT = 1; temp = 50 * (int) Duty_cycle; CCPR1 = temp; //On time } else PWM1_OUT = 0; } PIR1bits.CCP1IF = 0; //Clear int flag }
Hi, Try this as your interrupt routine: Code: #pragma interrupt ccpisr_hand void ccpisr_hand() { if(PIR1bits.CCP1IF == 1) if(PWM1_OUT == 1 ) //Will be 1 if we are at end of pulse { PWM1_OUT = 0; CCPR1 = 5000 - temp; //Off time } else { if(Duty_cycle > 0 && Duty_cycle < 97) { PWM1_OUT = 1; temp = 50 * (int) Duty_cycle; CCPR1 = temp; //On time } else PWM1_OUT = 0; } PIR1bits.CCP1IF = 0; //Clear int flag }