Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC Code - PWM (50% Duty Cycle)

Status
Not open for further replies.

devonsc

Advanced Member level 4
Joined
Nov 30, 2004
Messages
115
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Activity points
1,931
Hi there,

I'm a newbie in using PIC microcontroller and would like to ask something regarding the duty cycle of a PWM coding.

If its not too much trouble, can anyone briefly explain how do I determine the duty cycle of a PWM duty cycle in the coding? Is it true that 255 (decimal) is equivalent to 100% duty cycle while 0 (decimal) is equivalent to 0% duty cycle? If this is right, does it mean that I should write:

movlw d'127'

for a duty cycle of 50%? Advice needed..Please? Thanks in advance..
 

Your guess is correct: for 50% the number is 127d.
 

Thanks a lot.

By the way, I'm using PIC 16F876.
 

The PIC16f876 has 2 PWM modules with a resolution of 10bits. So your period could have a count of 1024. The data sheet gives formulas for calculating the duty cycle based on the frequency and resolution.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top