CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Does anyone have a WORKING code of power_pwm for 18Fxx31?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
40inD
Guest







Does anyone have a WORKING code of power_pwm for 18Fxx31?
PostPosted: Wed Sep 28, 2005 11:47 am     Reply with quote

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








PostPosted: Wed Sep 28, 2005 11:47 am     Reply with quote

sorry, led on C0 flashes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Sep 28, 2005 1:12 pm     Reply with quote

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







PostPosted: Sat Oct 01, 2005 9:47 am     Reply with quote

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 Smile
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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