PDA

View Full Version : Help with PWM pulse train



abuhafss
- 9th February 2014, 18:20
Hi Everyody

I am a newbie to PIC programming. In fact, just playing with LEDs to learn control of outputs.

I could not understand the term "CYCLE" used with command PWM. Can somebody spare a few moments to explain it?

Example:

a) Output required at pin B1, 10% duty cycle and frequency 410kHz - only internal oscillator 8MHz

b) Output required at pin B1, 10% duty cycle and frequency 410kHz - external oscillator 8MHz

c) Output required at pin B1, 10% duty cycle and frequency 410kHz - external oscillator 20MHz

I understand how to direct output to a particular pin and calculate the duty cycle. I just could not understand how to work out CYCLES for a particular frequency of the output pulse train against the frequency of the internal/external oscillator of a PIC.

Thanks for the help.

mpgmike
- 4th April 2014, 22:19
If I understand the PBP PWM and HPWM commands correctly, if you properly define your clock source (internal or external etc) and operating frequency through the OSCON register(s), the PCP takes it from there.

HPWM 1, 10, 410

Hope this helps.

Mike