View previous topic :: View next topic |
Author |
Message |
ives_13mg
Joined: 23 Sep 2008 Posts: 2
|
Why this program doesn't work? Switch LED... |
Posted: Tue Sep 23, 2008 12:16 pm |
|
|
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
|
|
Posted: Tue Sep 23, 2008 12:51 pm |
|
|
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
|
|
Posted: Tue Sep 23, 2008 12:59 pm |
|
|
Oh thanks... Stupid question!!! I'm sorry for this.. |
|
|
|