I want to use PIC16F877A pin C2 to control the brightness of the backround light of LCD display... with pulse width modulation.
I have FET connected to pin C2 and on/off control works fine.
Is there any example how to use PWM module for that purpose ?
I understand how pulse width modulation works in theory but I had no success to get it work though I tried it make to work in many ways ...
if you want please help me ...
I do not understand this ccs manual good example how to use it:
Code:
// For a 20 mhz clock, 1.2 khz frequency,
// t2DIV set to 16
// the following sets the duty to 50% (or 416 us).
long duty;
duty = 512; // .000416/(16*(1/20000000))
set_pwm1_duty(duty);
I'm very pleased for this good discussion forum ...
all the best for you all
-arto-
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
Posted: Sun Nov 24, 2013 12:53 pm
you need to:
** setup timer 2 for frequency control
and then
** setup the pwm module for PWM output
per the ccs manual
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
Posted: Mon Nov 25, 2013 7:47 am
fig 2 is a simple block diagram of a buck modulator
which is a classic way to use PWM for adjusting the output power of a fixed supply. with a 5V dc input - substitute a P channel FET for the transistor, and direct drive the gate with the PIC PWM Output to vary the power sent to an LED back light and your problem is solved.
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