Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

pic 16f877a using 2 pwmchannels

Status
Not open for further replies.

aswinishere007

Newbie level 3
Joined
Feb 2, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,306
hai,I am new to Pic microcontrollers.Is it possible to use the 2 PWM channls in PIC 16f877A simultaneously?i have a code for pwm in ccp1 module.I want two pwm for controlling two motors.How can i use ccp2 in pwm mode?I use MPLAB IDE,HI TECH C complier....pls anyone provide me the code
 

rparthiban69

Full Member level 4
Joined
Aug 1, 2012
Messages
225
Helped
19
Reputation
38
Reaction score
17
Trophy points
1,308
Activity points
2,524
Code:
unsigned int value1,value2;
void main()

{
	ADCON1=0X06;                                                                                                                                      ;
	TRISA=0XFF;
	TRISC=0X00;
	CCP1CON=0X0C;
	T2CON=0X04;
	//CCPR2L=0x3F;
	PR2=49;
	PORTA=0x00;
	PORTC=0x00;
	while(1)
	{
		ADCON0=0X80;
		//delay();
		ADGO=1;
		
		CCP1CON=0b00001100;
		CCPR1L=0b00000101;
		CCP2CON=0b00001100;
		CCPR2L=0b00000101;
	} 	
}

delay()
{                                                                                                                                                                                                                                                                                                 
	unsigned int i;
	for(i=0;i<200;i++);
}
Check this
 

Tahmid

Advanced Member level 5
Joined
Jun 17, 2008
Messages
4,758
Helped
1,791
Reputation
3,574
Reaction score
1,650
Trophy points
1,393
Location
Silicon Valley, California, USA (from Dhaka, Bangl
Activity points
30,545
hai,I am new to Pic microcontrollers.Is it possible to use the 2 PWM channls in PIC 16f877A simultaneously?i have a code for pwm in ccp1 module.I want two pwm for controlling two motors.How can i use ccp2 in pwm mode?I use MPLAB IDE,HI TECH C complier....pls anyone provide me the code
Yes it's possible to use both channels simultaneously. PWM module 1 settings are set by configuring CCP1CON. PWM module 2 settings are set by configuring CCP2CON. So, just configure CCP2CON for PWM mode just as you'd do for CCP1CON. Remember that both modules share the same time base - PR2. So they'll both operate at the same frequency. This shouldn't be a problem since you'll be controlling 2 motors.

Hope this helps.
Tahmid.
 
Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top