pulse generation problem

Thread Starter

lihle

Joined Apr 12, 2009
83
guys
help me out with a sample code to generate a pulse wave, where by i have to give the duty circle and the time.
duty cycle/100*period=Time constant.

lihle
 

Tahmid

Joined Jul 2, 2008
343
Hi,
What pulse generation are you talking about?
This is for a PIC18F45K20:
Rich (BB code):
//PWM output of 32kHz 50% duty cycle at PORTC2 
//Developed by: Tahmid 
//1st February, 2010 
//System clock: 4MHz 
//Clock source: XT Crystal 
 
void main(void){ 
     TRISC = 0; //PORTC OUTPUT 
     PORTC = 0; 
     PR2 = 30; //~32kHz 
     CCPR1L = 15; //Duty cycle 50% 
     CCP1CON = 0x0C; //CCP1CON = 00001100, Single output, Active High 
     T2CON = 4; //TMR2 on, prescale = 0 
     while (1); 
}
http://www.edaboard.com/ftopic379285.html

Hope it helps.
Tahmid.
 
Top