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

Why this program doesn't work? Switch LED...

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



Joined: 23 Sep 2008
Posts: 2

View user's profile Send private message

Why this program doesn't work? Switch LED...
PostPosted: Tue Sep 23, 2008 12:16 pm     Reply with quote

Hi. I'm confused! The pin P1C doesn´t change its state. Its state is HIGH, all the time. The PWM in P1B works but I have a problem in P1C. Why? Can you help me?
Code:
#include <16F690.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOCPD                    //No EE protection
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled

#use delay(clock=4000000)

#define P1A PIN_C5
#define P1B PIN_C4
#define P1C PIN_C3
#define P1D PIN_C2

void main(void)
{
  delay_ms(200); // power up delay

  setup_adc_ports(NO_ANALOGS | VSS_VDD);
  setup_comparator(NC_NC_NC_NC);
  setup_vref(FALSE);

  setup_timer_2(T2_DIV_BY_4, 74, 1);  // 3324 Hz
  set_pwm1_duty(151L);  // 50% duty cycle

  // Enable PWM pins P1B, P1C, and P1D for output.
  // Note:  P1A is done by the compiler.
  output_low(P1B);
  output_low(P1C);
  //output_low(P1D);

  // Steer the PWM output to all four P1x pins.
  //setup_ccp1(CCP_PWM_H_H | CCP_PULSE_STEERING_A
  //                       | CCP_PULSE_STEERING_B
  //                       | CCP_PULSE_STEERING_C
  //                       | CCP_PULSE_STEERING_D );
 
  setup_ccp1(CCP_PWM_H_H | CCP_PULSE_STEERING_B);
 
  while(1)
  {
      output_high(P1C);
      delay_ms(2000);
      output_low(P1C);
  }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 23, 2008 12:51 pm     Reply with quote

Quote:
while(1)
{
output_high(P1C);
delay_ms(2000);
output_low(P1C);
}

The pin P1C doesn´t change its state. Its state is HIGH, all the time.

Look closely at your LED blinking loop. How long will P1C (pin C3)
be in the "low" state ?

If you can't understand it, look at the code in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=34785
ives_13mg



Joined: 23 Sep 2008
Posts: 2

View user's profile Send private message

PostPosted: Tue Sep 23, 2008 12:59 pm     Reply with quote

Oh thanks... Stupid question!!! I'm sorry for this..
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