View previous topic :: View next topic |
Author |
Message |
artohautala
Joined: 17 Nov 2011 Posts: 187
|
any example to use PWM 1 and PWM 2 in PIC18F452 ? |
Posted: Tue Jan 27, 2015 9:09 am |
|
|
Hello,
I want to use PWM1 and PWM2 in PIC18F452 to control RGB power LED
to get different colours...
... maybe PWM1 and 2 to control R and G and software PWM for
B ...
is there any quick example hot to configure those PWM:s ?
please tell me
best regards
-arto- |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Jan 27, 2015 9:34 am |
|
|
in the CCS manual
have you read:
setup_CCPx ????
edited - ![Embarassed](images/smiles/icon_redface.gif)
Last edited by asmboy on Tue Jan 27, 2015 10:53 am; edited 3 times in total |
|
![](templates/subSilver/images/spacer.gif) |
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Tue Jan 27, 2015 9:53 am |
|
|
asmboy wrote: | in the CCS manual
have you read:
setup_PWMx ???? |
no I have not... I do not know where to find it?
I've read:
setup_power_pwm() , setup_power_pwm_pins() ,
set_power_pwm_override(), set_power_pwmX() , set_power_pwmx_duty(),
set_power_pwm_duty()...
but I do not know in which order to use them ...
and how to get things going...
thank for your answer
![Very Happy](images/smiles/icon_biggrin.gif) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19372
|
|
Posted: Tue Jan 27, 2015 10:12 am |
|
|
You don't.
Those are for the _power PWM module_ your chip only has a conventional module, so those do not apply.
Key is that on the standard PWM, the PWM, is a 'sub function' of the CCP module. Just look in the manual at 'setup_ccp', and then at the bottom ofthe page at 'set_pwmx_duty', and 'ccp1 overview'.
Then look in the examples at 'ex_pwm.c'
This is for a single PWM, but setup_ccp2, and set_pwm2_duty, do the same for the second PWM. |
|
![](templates/subSilver/images/spacer.gif) |
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Tue Jan 27, 2015 10:19 am |
|
|
Ttelmah wrote: | You don't.
Those are for the _power PWM module_ your chip only has a conventional module, so those do not apply.
Key is that on the standard PWM, the PWM, is a 'sub function' of the CCP module. Just look in the manual at 'setup_ccp', and then at the bottom ofthe page at 'set_pwmx_duty', and 'ccp1 overview'.
Then look in the examples at 'ex_pwm.c'
This is for a single PWM, but setup_ccp2, and set_pwm2_duty, do the same for the second PWM. |
OK!
that was very good advice ... no I think I'm going forward !
thank you so much !
all the best
-arto- |
|
![](templates/subSilver/images/spacer.gif) |
|