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 support@ccsinfo.com

c code of pic18f4431 not working

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



Joined: 05 Dec 2004
Posts: 31

View user's profile Send private message

c code of pic18f4431 not working
PostPosted: Sat Sep 13, 2008 8:54 am     Reply with quote

I wrote a C code of pic18f4431 and compiled success. Turn on the power I only see the PWM1 has 5v. PWM0 has 0v. the code is as follows:
Can someone help me !!!
Code:

#include <18f4431.h>
#device ADC=8
#fuses HS,NOWDT,nolvp
#use delay (clock=20000000)
#use fast_io(A)
#use fast_io(B)

void main()
{
 // setup_comparator(NC_NC_NC_NC);
//setup_vref(0);
  set_tris_a(0b11111111);         // A2-3 outputs
  //set_tris_b(0b11010100);      // B0-1,B3,B5 outputs

set_power_pwm_override(0, false, 1);
setup_power_pwm(PWM_CLOCK_DIV_4 | PWM_FREE_RUN |
PWM_DEAD_CLOCK_DIV_4,1,10000,1000,0,1,0);
setup_power_pwm_pins(PWM_COMPLEMENTARY ,PWM_OFF, PWM_OFF, PWM_OFF);
 
set_power_pwm0_duty(4000);
while(1);
   }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Sep 13, 2008 11:38 am     Reply with quote

Post your compiler version.

Unless somebody else helps you first, I can't work on this until tomorrow.
lgeorge123



Joined: 05 Dec 2004
Posts: 31

View user's profile Send private message

PostPosted: Sun Sep 14, 2008 3:45 am     Reply with quote

I use 4.074 version.
Ttelmah
Guest







PostPosted: Sun Sep 14, 2008 10:29 am     Reply with quote

The override won't work. You have the PWM in 'complementary' mode. Look at the note in Figure 17-2 of the data sheet. remember that '0' is an 'even' number as far as channel numbers are concerned.
I think what is happening, is that the compiler is trying to handle this override, and is automatically applying it to channel one instead, which in complementary mode, results in PWM0=0 PWM1=1.

Best Wishes
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