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
Visit site
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:

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.
 

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
 

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
 

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.
 

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.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…