initialize pwm of pic18

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

initialize pwm of pic18

Postby bear » Wed Jul 06, 2011 5:59 pm

this is my initialze..

PR2 = 0xff;
T2CON = 1; //enable timer 2
T2CON = 1; //timer 2 prescale
CCP1CON = 0b00111100;
CCP2CON = 0b00111100;
CCPR1L = 0;
CCPR2L = 0;

my pwm didnt gives output..
can someone help??
whats missing and wrong??
bear
Apprentice
 
Posts: 46
Joined: Tue Oct 05, 2010 2:11 am

Re: initialize pwm of pic18

Postby robosang » Wed Jul 06, 2011 6:20 pm

brother.... how you activate timer 2? Look at your code...
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: initialize pwm of pic18

Postby bear » Wed Jul 06, 2011 6:31 pm

thats not the real prob..
idont know how to initialize..

how to initialize timer??
bear
Apprentice
 
Posts: 46
Joined: Tue Oct 05, 2010 2:11 am

Re: initialize pwm of pic18

Postby robosang » Thu Jul 07, 2011 9:26 pm

look at datasheet.... :mrgreen:

Not to say you do not want to learn, even copy also you are wrong.
bear WROTE: PR2 = 0xff;
T2CON = 1; //enable timer 2
T2CON = 1; //timer 2 prescale
CCP1CON = 0b00111100;
CCP2CON = 0b00111100;
CCPR1L = 0;
CCPR2L = 0;


Why is T2CON appear twice and assign with same value? Ever think of that? You need to learn, what for you copy without learning?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 3 guests

cron