|
|
View previous topic :: View next topic |
Author |
Message |
lgeorge123
Joined: 05 Dec 2004 Posts: 31
|
c code of pic18f4431 not working |
Posted: Sat Sep 13, 2008 8:54 am |
|
|
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
|
|
Posted: Sat Sep 13, 2008 11:38 am |
|
|
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
|
|
Posted: Sun Sep 14, 2008 3:45 am |
|
|
I use 4.074 version. |
|
|
Ttelmah Guest
|
|
Posted: Sun Sep 14, 2008 10:29 am |
|
|
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 |
|
|
|
|
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
|