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

pic16f628 pwm problems!!!!!!

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



Joined: 10 May 2004
Posts: 17
Location: barcelona

View user's profile Send private message

pic16f628 pwm problems!!!!!!
PostPosted: Fri Nov 26, 2004 3:37 pm     Reply with quote

hello,
i have a problem with the PIC16F628 and the outputs CCP1, A3 and A4.
I use the CCP1 how PWM for control a dc motor with a MOSFET. For test i use a led, and i want to see the light intensity, this intensity tell my about the duty cycle is, but not works. The output is 5V always... when i put the duty to 0... the output is the same... and the intensity of led not change... the state not change...
another problem are the outputs A3 and A4.... A3 is always 5V and A4 not respond... i think that the problem is with the comparator setup because this pins are the comparator inputs.... i dont know what's happend...
the output A2 works correctly, it lights every second...
i put my test code here...

anybody can help me???

thanks
Alex

Code:


#include <16F628.h>
#fuses HS,NOWDT,NOPROTECT,NOMCLR,NOBROWNOUT
#use delay(clock=20000000)
//#use rs232(baud=31250, xmit=PIN_A1, parity=N, bits=8)


main() {

  byte value = 0x7F;

  setup_comparator(NC_NC_NC_NC);
  setup_ccp1(CCP_PWM);   // Configure CCP1 as a PWM
  setup_timer_2(T2_DIV_BY_16, 127, 1);  // f=1.2 Khz

   while (TRUE) {
     output_high(PIN_A2);
     output_high(PIN_A3);
     set_pwm1_duty(127);
     delay_ms(500);
     output_low(PIN_A2);
     output_high(PIN_A3);
     set_pwm1_duty(0);
     delay_ms(500);
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 26, 2004 3:57 pm     Reply with quote

What is your version of the compiler ?
nicenoise



Joined: 10 May 2004
Posts: 17
Location: barcelona

View user's profile Send private message

PostPosted: Fri Nov 26, 2004 4:29 pm     Reply with quote

my version is 3.200...
now, i changed to the old 3.187 and the pwm works.... Smile
but, the outputs A3 and A4 not works... its the same problem...

what do you think??
thanks

Alex
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 26, 2004 4:37 pm     Reply with quote

Vs. 3.200 should not be used. It was the first version of the 3.2xx
series, and it has lots of bugs.

The problem with pin A3 is because your test program never sets
pin A3 to a low level. Both statements set it to high level.

The problem with pin A4 is because that pin has an open-drain output.
The PIC can't drive that pin to a high level by itself. You need to add a
pull-up resistor to that pin. You can use a 4.7K resistor.
nicenoise



Joined: 10 May 2004
Posts: 17
Location: barcelona

View user's profile Send private message

PostPosted: Fri Nov 26, 2004 4:54 pm     Reply with quote

ok
thanks for your help!!!!!!
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