View previous topic :: View next topic |
Author |
Message |
nazoa
Joined: 09 Feb 2007 Posts: 56
|
Setting up pin RB3 as PWM output |
Posted: Sun Feb 18, 2007 3:49 am |
|
|
Hello,
I have a pretty basic question regarding PWM. I want to set up RB3 as a sole PWM output but I am not sure how it can be done. Can anyone suggest what the setup_power_pwm_pins statement should be? Note that I need pin RC1 to be set as an ordinary logic output.
Thanks! |
|
|
Ttelmah Guest
|
|
Posted: Sun Feb 18, 2007 5:19 am |
|
|
As always with questions like this, _we need to know what chip you are using_. The available options change from PIC to PIC, and though your reference to 'power_PWM', reduces the number of possible chips somewhat, without this extra data, it is not possible to be sure.
Assuming this is something like a xx31 chip, then the option 'PWM_ODD_ON', enables the odd (PWM1,3,5 etc.) output channels only. You can also override any pin on these PWM units, even if enabled for PWM, using the override register (needs manual definition).
Best Wishes |
|
|
nazoa
Joined: 09 Feb 2007 Posts: 56
|
PWM |
Posted: Sun Feb 18, 2007 6:55 am |
|
|
Thanks for the reply Ttelmah.
Yeah, the chip I am using is the 18F4550. I am unsure how a pin is associated to one of the four PWM channels. So, I am looking for how I need to write the arguments for setup_power_pwm_pins statement to get RB3 going as the sole PWM output.
Thanks! |
|
|
Ttelmah Guest
|
|
Posted: Sun Feb 18, 2007 11:02 am |
|
|
On the 4550, CCP2, is a normal PWM, not an enhanced PWM (only CCP1 supports the enhanced features). Just setup CCP2 for PWM, and only the one pin is used.
Best Wishes |
|
|
nazoa
Joined: 09 Feb 2007 Posts: 56
|
|
Posted: Sun Feb 18, 2007 3:58 pm |
|
|
The thing is that the data sheet tells me that RC1 is the default ouput for CCP2 and to select RB3 instead the 'CCP2MX' bit needs to be set to 0. Now, how do you do this with the CCS compiler?
Thanks! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 19, 2007 2:00 am |
|
|
Quote: | Now, how do you do this with the CCS compiler? |
It's done with the #fuses statement. Look near the start of the 18F4550.h
file. You'll see a list of fuse settings. The ones that control the CCPMX
feature start with "CCP".
Last edited by PCM programmer on Thu Feb 17, 2011 2:18 pm; edited 1 time in total |
|
|
nazoa
Joined: 09 Feb 2007 Posts: 56
|
PWM |
Posted: Mon Feb 19, 2007 4:31 am |
|
|
Thanks!
You're right, what I need is
#fuses CCP2B3 |
|
|
|