In my project, I have to design single phase inverter using PIC microcontroller 16F877A. The problem is, I don't know about the code to generate PWM using this PIC. Can anyone give me any sample of the source code to program my PIC?
I think that's wrong.
With PR2 = 99, you will have 100% duty cycle with CCPR1L loaded with 100, 50% duty with 50, 25% duty with 25 and 0% with 0.
It goes like:
CCPR1L value = (Required Duty Cycle (in %) / 100) * (PR2 + 1)
So, with PR2 = 29, you will have 20% duty cycle with CCPR1L = 0.2 * 30 = 6
You are correct.
I think Alberto must have been using a program call "Mister E PIC multi-cal" to get his figures. That program gives absolute rubbish output for PWM calculations and I have just deleted it from my PC.
Hai...
Thanks for your information. i'm really forgot 'bout that...so now, i should change the calculation part and put 4 as a TMR2 prescale value right? thanks a lot
Other than previously discussed, it is possible to generate pwm without CCP module(PWM hardware) onboard. This is what we called software pwm. The method required you to write codes to generate the PWM rather than rely on the hardware. However, hardware(PWM) is more reliable compared to software version.
I'm not going to make you confuse here but just showing how colorful our world are..