|
|
View previous topic :: View next topic |
Author |
Message |
Fabri
Joined: 22 Aug 2005 Posts: 275
|
PWM on CCP2 and P1B |
Posted: Thu Nov 10, 2011 3:32 am |
|
|
Hi to all,
I'm in trouble because I need to add PWM in project with PIC18F4525. I configured CCP2 as PWM and work fine with it pin RC1/CCP2. Actually my pin CCP2 is used and I need to have PWM in other pin, for example RD5/P1B. I tryed some setup unsuccessfully.
Somebody can help me to configure PWM or suggest me a link to study ?
Regards,
Fabrizio |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu Nov 10, 2011 3:46 am |
|
|
Where you can put a signal, is down to the hardware.
For this look at the data sheet.
'No' you cannot have CCP2 on RD5. The only other place you can put CCP2, is RB3. Again looking at the data sheet, this is controlled by a fuse. Then looking at the fuse options in CCS, the fuses controlling this are CCP2B3 and CCP2C1, allowing you to route the CCP2 signal to B3, or C1 (the default).
So add the fuse CCP2B3, and CCP2, will be on pin B3.
Best Wishes |
|
|
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Thu Nov 10, 2011 4:06 am |
|
|
Yes, I already think the option of pin B3 but it's also used and I don't want do some hardware change. I'll study datasheet better.
Just one simple question:
There's a possibility to haven't hardware PWM output to pin B3 or C1 and use PWM, with it's interrupt, in software ?
In this way I can change state of pin manually.....
I think also in PWM software but I don't realize how have 2Khz with resolution of 100 step.
Regards,
Fabrizio |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu Nov 10, 2011 5:18 am |
|
|
You can get an output using PWM1, but you asked about PWM2....
If you are happy to use PWM1, then RC2, is the default output for this in compatible PWM mode. Table 16-1 in the data sheet, and Figure 16-1 (CCP1/P1A pin).
Using the other ECCP pins, may be 'possible', but depends on what you are using the other ECCP pins for (input or output). If you select 'full bridge' mode, then with forward selected, P1B, can be modulated, and with reverse selected P1D can be modulated. However the ECCP, doesn't have an output override capability, so the other P1 pins are only potentially available for use as _inputs_ in this mode.
Using a timer, interrupt, not really. The overhead will become prohibitive at this sort of frequency/interval, and the short intervals will just not work.
Best Wishes |
|
|
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Thu Nov 10, 2011 5:25 am |
|
|
by the way... I use CCP1 stage as input capture for control one other software PWM with 100 Hz frequency. I think is impossible to have CCP1 as input capture and PWM1 at the same time....
Anyway thanks to try to help me.....
Regards,
Fabri |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|