View previous topic :: View next topic |
Author |
Message |
kevin5k
Joined: 08 Jan 2007 Posts: 41
|
No Looping...Software or PIC or Me? |
Posted: Fri Jan 12, 2007 6:12 pm |
|
|
Hi, I'm currenlty using this code to make an LCD blink on & off.
================================
#include <16F876A.h>
#device ICD=TRUE
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP, DEBUG
#use delay(clock=4000000)
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while (1);
{
output_low(PIN_B0);
delay_ms(1000);
output_high(PIN_B0);
delay_ms(1000);
}
================================
Somehow , the true statement is never executed! It will only execute if I use a 0 value in the while (expression). Is this just me? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 12, 2007 6:28 pm |
|
|
Yes, it is. Look at the end of the statement. What is there that
shouldn't be there ? |
|
|
David_K
Joined: 14 Nov 2006 Posts: 5
|
|
Posted: Fri Jan 12, 2007 7:08 pm |
|
|
I did that on an 'if' statement once, I did a bunch of work on my code then had to hand it off to another engineer. It took him 2 days to find that stupid thing...
David |
|
|
kevin5k
Joined: 08 Jan 2007 Posts: 41
|
|
Posted: Fri Jan 12, 2007 7:11 pm |
|
|
Don't quite get.....
PCM programmer wrote: | Yes, it is. Look at the end of the statement. What is there that
shouldn't be there ? |
|
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Fri Jan 12, 2007 7:25 pm |
|
|
To further clarify, PCMs question is:
while (1); <======= What is on the end of this line?
What effect would it have on the statement? |
|
|
kevin5k
Joined: 08 Jan 2007 Posts: 41
|
|
Posted: Fri Jan 12, 2007 8:01 pm |
|
|
Oooh..............Blind me......
dyeatman wrote: | To further clarify, PCMs question is:
while (1); <======= What is on the end of this line?
What effect would it have on the statement? |
|
|
|
|