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 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
 

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
 
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.
 
ADGO refers to the ADGONE bit in the 16F877A. How a bit is defined in the compiler is found in the related header file. So, you should consult the header file for PIC16F877A for your compiler.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top