Dec 12, 2012 #1 D 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: Dec 12, 2012
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; } } }
Dec 13, 2012 #2 hexreader Advanced Member level 2 Joined Apr 7, 2011 Messages 549 Helped 196 Reputation 396 Reaction score 197 Trophy points 1,323 Location England Activity points 5,833 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.
Dec 13, 2012 #3 D 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 hexreader said: 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. Click to expand... how to change to RB3? i need 3 pwm port to 3 control motor thank you
hexreader said: 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. Click to expand... how to change to RB3? i need 3 pwm port to 3 control motor thank you
Dec 13, 2012 #4 hexreader Advanced Member level 2 Joined Apr 7, 2011 Messages 549 Helped 196 Reputation 396 Reaction score 197 Trophy points 1,323 Location England Activity points 5,833 david43 said: how to change to RB3? i need 3 pwm port to 3 control motor thank you Click to expand... 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
david43 said: how to change to RB3? i need 3 pwm port to 3 control motor thank you Click to expand... 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
Dec 13, 2012 #5 Tahmid Advanced Member level 6 Joined Jun 17, 2008 Messages 4,756 Helped 1,798 Reputation 3,588 Reaction score 1,656 Trophy points 1,413 Location Berkeley, California Activity points 30,585 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.
Dec 13, 2012 #6 D 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 Tahmid said: 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. Click to expand... Do you have any source code about using timer1 to generate the pwm? thank you
Tahmid said: 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. Click to expand... Do you have any source code about using timer1 to generate the pwm? thank you