Thank you Mister e,
It never occurred to me to read the data sheet, especially any part of section 9. I have since found the problem. Although I'm not sure why yet, somehow on power-up intcon<1> gets set even thought the data sheet indicates that the intcon register 'should' power up to all zeros. Anyway, if I place the clear intcon<1> , ext int flag bit, code just before the sleep command rather than after the problem goes away.
However, I do appreciate the code help with the assembler code:
asm
clrf 32h
endasm
The misuse of that explains why I needed the CLEAR statement just prior to the snipet of code as they should be redundant statements, I think. Anyway the reason for that is when exiting sleep the LCD would not work properly. After days of haed wracking I finally took a look at the PBP commands for the LCD, i.e. LCDOUT, LCDIN etc. What I found was when the LCDOUT command is issued it looks at a flag bit called LCDINIT and if the bit is clear it then initializes the LCD, if set it does not go through the initialize routine. So, since exiting sleep is a just a continuation of the code the LCDINIT flag is still set so subsequent calls to LCDOUT ignore the initialization routine even though the LCD was turned off. Therefore the LCDINIT flag needs to be cleared after exiting sleep. Guess where the LCDINIT flag bit, among others, is stored by PBP, 0x32.
Thanks for your assistance!
Bookmarks