Quote Originally Posted by mister_e View Post
Be careful with 18Fs.. when you write to a PORT you should use LATx instead of PORTx. If you write to adjacent bits, you should write to a shadow register first, then copy it to the whole port to avoid the Read-Modify-Write behaviour.

I would tend to change the LCDOUT statement... reading the Magn bit (from PORTD.7), save the result to a Temp variable then after show the result. When writing to Magn, you use LATD.7.
I've never used, or had to use, LATD.x on the 18F's.
But if you say it takes care of some of the R-M-W issues, then it must be true.