|
|
View previous topic :: View next topic |
Author |
Message |
40inD Guest
|
Does anyone have a WORKING code of power_pwm for 18Fxx31? |
Posted: Wed Sep 28, 2005 11:47 am |
|
|
I use this code for first expirience in power pwm in 4431, but it does not work.
Code: |
void setup_pwm()
{
setup_power_pwm (pwm_clock_div_4 | pwm_free_run, 1, 10000, 1000, 0, 1, 0);
setup_power_pwm_pins (PWM_ODD_ON, PWM_ODD_ON, PWM_ODD_ON, PWM_ODD_ON);
return ;
}
void main()
{
setup_pwm();
while (1){
//varying brightness of 4 leds as indication that pwm works
set_power_pwm0_duty (4095);
set_power_pwm2_duty (1024);
set_power_pwm4_duty (2048);
set_power_pwm6_duty (4095);
output_high(pin_c0);
delay_ms(100);
set_power_pwm0_duty (4095);
set_power_pwm2_duty (2048);
set_power_pwm4_duty (4095);
set_power_pwm6_duty (0);
output_low(pin_c0);
delay_ms(100);
set_power_pwm0_duty (2048);
set_power_pwm2_duty (4095);
set_power_pwm4_duty (0);
set_power_pwm6_duty (1024);
output_high(pin_c0);
delay_ms(100);
set_power_pwm0_duty (1024);
set_power_pwm2_duty (0);
set_power_pwm4_duty (1024);
set_power_pwm6_duty (2048);
output_low(pin_c0);
delay_ms(100);
}
} |
Only led on C1 flashes but leds on pwm0,2 are always on and leds on pwm 4,6 are always off.
Where is the error??? |
|
|
Guest
|
|
Posted: Wed Sep 28, 2005 11:47 am |
|
|
sorry, led on C0 flashes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 28, 2005 1:12 pm |
|
|
Look at the CCS example file, EX_POWER_PWM.C.
You will have this file if your version of PCH is 3.232 or higher.
Look for it in this folder: c:\Program Files\Picc\Examples |
|
|
40inD Guest
|
|
Posted: Sat Oct 01, 2005 9:47 am |
|
|
I have version 3.203. I guess it does not support these functions?
So, i'm now working directly with registers and i'm happy |
|
|
|
|
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
|