Re: Can't set portb.0 low
Shawn,
Have you tried?
LATB.0 = 0
Re: Can't set portb.0 low
I have never used that, but will try it this evening. When and why should LAT be used?
Re: Can't set portb.0 low
Quote:
Originally Posted by
spcw1234
I have never used that, but will try it this evening. When and why should LAT be used?
When you use 18F series. Because of the RMW issue!!!
Re: Can't set portb.0 low
Using LAT did not work. I don't think it is RMW as I am not reading the port, I already know it's state is high, I just want to make it low.
Thanks for the help!
Re: Can't set portb.0 low
OK, I got it working, after I commented out the line below it worked. Took me a while to understand why, then I saw it... :) The gosub wait1 is to wait for the ACK from the LCD display. If no ACK, it reboots the display. Well I jump to a routine that waits for the ACK, then return and wait again without sending another command to the display. Stupid little mistake trying to shrink the program to save some flash space.
Code:
shutdown:
serout2 tx, baud, ["s", 0, 2, 2, white1, white2, "- GOOD BYE -", $00] : gosub wait1
; gosub ln3blank : gosub wait1 ;PORTB.0 CAN GO LOW WITH THIS LINE COMMENTED OUT??????
serout2 tx, baud, [$59, $03, $00] : gosub wait1
pause 500
PORTB.0=0 'shutdown main power relay NOT GOING LOW??????????
pause 5000 'wait for relay to drop out
goto start 'if processor is still running, then reboot
ln3blank:
serout2 tx, baud, ["s", 0, 3, 2, white1, white2, " ", $00] : gosub wait1
return
wait1: 'WAIT FOR ACK FROM DISPLAY
serin2 rx, baud, 500, initdisp, [a] 'wait 500ms for serin, else goto wait2
if a<>6 then waitfail '???? 'check for ACK, if not then reinitialize display
return
Re: Can't set portb.0 low
One thing I often do to "see" if my program gets to a certain point is to insert a "blink LED" routine at the point in question.
(assuming you have another free I/O pin). That way you can blink the LED to see if your program ever gets to that point.
Or you could do a GOSUB BLINKY routine and use it at several points in your program with a variable loaded with a blink count just before the gosub.
It's times like these that you have to drop back to basic troubleshooting techniques. One thing you could have done is to set aside your original program and just did a very simple LED blinky test to check the PortB.0 pin... then once you are convinced it is not the pin or your configs... you know it must be in software somewhere..
glad you found the problem.