PDA

View Full Version : pbp bug or incompetence?



George
- 26th June 2008, 06:43
I'm trying to write some code for an 18f8722 but am having some problems. If I say

PORTA.0 = 1
Pause 1000
PORTA.3 = 1

Port A.0 turns on then a second later Port A.3 turns on and port A.0 turns off - It works if I say

PORTA.0 = 1
pause 1000
PORTA = 9

But that's not really what I'm wanting to do. Here's some cutting and pasting of code - After I had the issue I wrote the simple code above to see what would happen and it does the same thing.

DEFINE OSC 10


TRISA = %00000000
TRISB = %00000000
TRISD = %11111111
TRISH = %00000000
TRISJ = %00000000
PORTA = 0
PORTH.0 = 0
PORTJ = 0
CMCON = 7 'DISABLE COMPARITOR
' RAM Assignments and Variables
' -----------------------------
RELAYS var PORTA
Retract Var PORTA.0
Extend var PORTA.1
MtrPwr var PORTA.3

***Blah Blah Blah***

BatchStart:

mtrpwr = 1
stepmtr = 1 'activate valve stepper
stepdir = 0 'open valve
steps = valveopen
gosub stepdrive
stepper = 0
for b1 = 0 to InjectTime
pause 10
if estop = 0 then Emergstop
next b1

stepdir = 1 'close valve
gosub stepdrive
stepper = 0

extend = 1
stepmtr = 2 'full flow
stepdir = 0
steps = fullspeed
stepper = 0 'de-energize coils
for b2 = 0 to 1000
if compactreed = 0 then Compact
pause 10
if estop = 0 then Emergstop
next b2

goto error1

paul borgmeier
- 26th June 2008, 06:57
PORTA.0 = 1
Pause 1000
PORTA.3 = 1


You need to set the ports as digital ... add

ADCON1 = $0F

I would also suggest using the latches instead of setting the ports directly (but not the cause of your troubles). CMCON POR defaults to 7 so you do not need to set it unless you want to be sure.

George
- 26th June 2008, 07:58
Ahhhh - so incompetence then, I did think that was more likely to be the case! Thanks heaps for your help - it's not an issue I've come across before, Cheers

BigWumpus
- 27th June 2008, 23:33
Just read about the LAT-registers in 18F-devices !!!!!!!!