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

pic18f4550 pwm rc2 change to rc3

Status
Not open for further replies.

david43

Newbie level 3
Joined
Dec 12, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
Hi all,
How to change the pwm to rc3 or other place??
now it is using the rc2.
i find PSTRCON to change the port
but it not work and can't build it.
i find pic 18f4550 datasheet but seem not have PSTRCON register

PHP:
#include <pic18.h>       
__CONFIG(1,HS&CPUDIV1) ;  
__CONFIG(2,WDTDIS) ;     
__CONFIG(3,PBADDIS) ;     
__CONFIG(4,XINSTDIS) ;   
unsigned char pwmbuf;
void main(void)
{	
	OSCCON=0X00;    		
	ADCON1=0X0f;            
  	TRISC=0B00000000;   
	PORTC=0B00000000;      
	CCP1CON=0xc;	       
	PR2=63;              
	T2CKPS1=0;
	T2CKPS0=0;           	
	TMR2ON=1;	         	
	//PSTRCON=0b00000100;
	pwmbuf=0;              

	CCPR1L=pwmbuf;          
  	while(1)
  	{ 		   		
   		
   			pwmbuf++;	    
			CCPR1L=pwmbuf;	
if(pwmbuf==100)
pwmbuf=0;
   		}    	
  	}
}
 
Last edited:

hexreader

Advanced Member level 2
Joined
Apr 7, 2011
Messages
536
Helped
194
Reputation
392
Reaction score
196
Trophy points
1,323
Location
England
Activity points
4,680
My reading of the datasheet is this:

There is no RC3 pin.

PWM output can be on RC1, RC2 or RB3 (the pins marked CCP1 or CCP2). I see no other options.
 

david43

Newbie level 3
Joined
Dec 12, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
My reading of the datasheet is this:

There is no RC3 pin.

PWM output can be on RC1, RC2 or RB3 (the pins marked CCP1 or CCP2). I see no other options.
how to change to RB3?
i need 3 pwm port to 3 control motor
thank you
 

hexreader

Advanced Member level 2
Joined
Apr 7, 2011
Messages
536
Helped
194
Reputation
392
Reaction score
196
Trophy points
1,323
Location
England
Activity points
4,680
how to change to RB3?
i need 3 pwm port to 3 control motor
thank you
There are only 2 CCP modules in this PIC, so only two hardware PWM outputs are possible.

I have heard talk of software PWM, but know nothing about it.

Maybe the simple solution is to change to another PIC that has more CCPs
 

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
If you require 3 PWM outputs, use CCP1 and CCP2 for 2 PWM outputs and generate the third using software PWM using, for example, Timer 1.

There are PICs with 3 (or more) hardware CCP modules. One example is PIC16F777.
 

david43

Newbie level 3
Joined
Dec 12, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
If you require 3 PWM outputs, use CCP1 and CCP2 for 2 PWM outputs and generate the third using software PWM using, for example, Timer 1.

There are PICs with 3 (or more) hardware CCP modules. One example is PIC16F777.
Do you have any source code about using timer1 to generate the pwm?
thank you
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top