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

18f4431 power control pwm module problem

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



Joined: 08 Jan 2005
Posts: 6
Location: Belfort, France

View user's profile Send private message

18f4431 power control pwm module problem
PostPosted: Sat Jan 08, 2005 3:53 pm     Reply with quote

hey everyone;

I'am working with this PIC on a project and I need to use 4 independant PWM sgnals.
Here is the deal..i've tried everything..checked most forums and and just can't get it to work : NO pwm signal at all on the output pins no matter what I do.

Here is the program I am currently using (programming under CCS):

Code:

#include <18F4431.h>

#use delay(clock=10000000)
#fuses NOWDT, HS, NOPROTECT, NOLVP, NOPWMPIN, HPOL_HIGH, LPOL_HIGH



void main()
{

  PTCON0 = 0;  // Time Base config : Free running mode
  PWMCON0 = 01001111;   // PWM 0 to 5 independant mode

   //  Fpwm = 10 kHz : Fosc = 10Mhz   =>  PTPER = 0x03E8
   //                            Fosc = 10Mhz   =>  PTPER = 0x00fa
   PTPERH = 0x00;
   PTPERL = 0xfa;
 
   OVDCOND = 0xff; //pwm output controlled by duty cycle
   OVDCONS = 0;

   FLTCONFIG = 0b10000111;   //fault A config

   PDC0L = 0xfa;
   PDC0H = 0x00;
   PDC1L = 0xfa;
   PDC1H = 0x00;
   PDC2L = 0xfa;
   PDC2H = 0x00;
   PDC3L = 0xfa;
   PDC3H = 0x00;

   PWMCON1 = 0b00000001;    // Output overides synched wrt PWM timebase
   //PWMCON1 = 0       //  (Special Event Trigger) not used

   DTCON = 0;               // no dead band timer
   PTCON1 = 0b10000000;         // Activate PWM Time Base*/



  // I also added this just to check if this module was working
  // (and it does work perfectly...but no use for this project :) )
   setup_ccp1(CCP_PWM);
   setup_timer_2(T2_DIV_BY_4,249,1);
   set_pwm1_duty(200);
}




Can anyone see what I'm missing out..??

thanks

michael
bluetooth



Joined: 08 Jan 2005
Posts: 74

View user's profile Send private message

Fault input?
PostPosted: Sat Jan 08, 2005 4:11 pm     Reply with quote

Is /FLTA driven low (or not pulled up)?

Try putting an 0x80 in FLTCONFIG to disable /FLTA assuming your hardware can stand what could happen in a fault condition with the outputs being driven!

Good luck....
nalixis



Joined: 08 Jan 2005
Posts: 6
Location: Belfort, France

View user's profile Send private message

PostPosted: Sat Jan 08, 2005 4:38 pm     Reply with quote

you know what..i just tried to correct the FLTCONFIG register, and guess what : IT WORKS !

thanks very much for your help..it was indeed this f..king register that was blocking everything.

So just one more question if I may : was exactly is this register used for and what was I doing wrong (knowing that absolutely nothing is plugged to the chip execpt for the power supply and reset )

thanks again

michael
bluetooth



Joined: 08 Jan 2005
Posts: 74

View user's profile Send private message

PostPosted: Sat Jan 08, 2005 5:47 pm     Reply with quote

Glad it works.....


From the data sheet (a VERY necessary document in general and for this part in particular):


17.12 PWM Fault Inputs

There are two fault inputs associated with the PWM
module. The main purpose of the input fault pins is to
disable the PWM output signals and drive them into an
inactive state. The action of the fault inputs is
performed directly in hardware so that when a fault
occurs, it can be managed quickly and the PWMs
outputs are put into an inactive state to save the power
devices connected to the PWMs.
The PWM fault inputs are FLTA and FLTB, which can
come from I/O pins, the CPU or another module. The
FLTA and FLTB pins are active-low inputs so it is easy
to “OR” many sources to the same input.
The FLTCONFIG register (Register 17-8) defines the
settings of FLTA and FLTB inputs.

17.12.1 FAULT PIN ENABLE BITS
By setting the bits FLTAEN and FLTBEN in the
FLTCONFIG register, the corresponding fault inputs
are enabled. If both bits are cleared, then the fault
inputs have no effect on the PWM module.

------------

You should read the rest of that section as well.... it's a really handy input if your load can generate a /FLT signal when it's having a problem (typically excess current). This will significantly reduce the odds of your letting the smoke out of your drivers!!!!

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