PDA

View Full Version : To no avail . . .



Archangel
- 20th January 2008, 08:56
Hi Everyone,
This is my first use of a 12F675, and I used some of Bruces code, to BCD control the time period from a lookup table and it works really well. I am using his code to control LED off time, But I am trying to control on time using IF / THEN loops and the code simply ignores the IF / THEN loop as if it simply said 250. If I substitute a number in the B0 variables place it uses that number. Anyone have an idea why the IF/Then loop has no effect? I have moved it around within the code to no avail.
Thank You
JS


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF

PCON = %00000011 ' BOD off, No POR flag set
DEFINE NO_CLRWDT 1
OSCCAL = %1111100 '
CMCON = 7 ' disable analog comparators
ANSEL = 0 ' disable A/D module, all digital
WPU.4 = 0 ' disable weak pull up on GPIO.4
B0 VAR BYTE
X VAR WORD

Index VAR BYTE

LED VAR GPIO.5

TRISIO = %00011111 ' RA0 to RA3 inputs for DIP switch

OPTION_REG = %11111111




Main:
IF (GPIO.4 = 1) THEN
B0 = 2500
else
B0 = 250
endif

Index = GPIO & $0F ' Read DIP switch AND mask result
LOOKUP2 Index,[200,300,400,500,600,700,800,900,1000,2000,_
3000,4000,5000,6000,7000,8000],X


HIGH LED
PAUSE b0
LOW LED
PAUSE X

GOTO Main

END
POKECODE @$3FF, $50 ' reintroduces osscal correction data

Acetronics2
- 20th January 2008, 09:04
Hi,

I note :

B0 var Byte ... and further B0 = 2500 ...

so, 255 is the maximum possible value for B0

Alain

Archangel
- 20th January 2008, 09:11
Hi,

I note :

B0 var Byte ... and further B0 = 2500 ...

so, 255 is the maximum possible value for B0

Alain
<h2><font color=red> THANKS! that was it !</h2></font color>
That was a BOZO not a typo :)

Acetronics2
- 20th January 2008, 09:30
[QUOTE=Joe S.;49321That was a BOZO not a typo :)[/QUOTE]

Glad to see you're happy ...

Alain

skimask
- 21st January 2008, 05:05
That was a BOZO not a typo :)

Since you're using a 12F675, how much accuracy do you need with the delay?
If a lot of accuracy isn't needed, how about throwing a pot on a pin and using the POT command for a the delay?
It would save you 3 pins to do other stuff with at the very least, and you can still scale the delay from a low to a high end with a simple software change.

Archangel
- 21st January 2008, 05:25
Hi Jeremy,
I might do that, this device only needs to do what it does, but those extra pins could be used for more on time options like 500, 1000, or maybe the pot command might control that.
JS