Tony, Thanks for the pointer. Both you and Rich sent routines to perform the function differently. This is an old program that was written in the heat of the battle and not very elegant. Unfortunately, there are about three other table reads like this for other functions that will also occasionally lose it. I'm trying to understand why the read doesn't work sometimes (very rarely). In your other message you mention not to trust PCLATH. Can it change somehow after I load the high address byte in? Interrupts are disabled during this portion of the program. Thanks for your help. > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of K|bek Tony > Sent: Monday, October 23, 2000 2:20 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]: Table bug > > > Hi, not really sure what is wrong with it, > but as it intermittent, my guess is probably context > saving during IRQ ? positive thats ok ? and that the > var offset is not touched inside irq also ? > > Further a snippet that might help :) > ( would perform the same function ) > > ; > ************************************************** > ********************* > ; > ; TX_ADD_HEX - Add two bytes of ASCII decimal > (0-9, A-F) in out buffer > from nibbles > ; in W-reg > ; NOTE uses TWO deep stack ( nested calls ) !! > ; > TX_ADD_HEX > MOVWF Temp ; save byte temporarily > SWAPF Temp,W > CALL TX_ADD_NIBBLE ; first one > MOVF Temp,W ; get back temp > ; and add second one > TX_ADD_NIBBLE > ANDLW 0x0F ; mask out top nibble, > preserv low nibble > ADDLW 0xF6 ; add 246, to check if > 0-9 or a-f, w=nibble+246 > BTFSC STATUS,C ; if carry set then a-f > ADDLW 0x07 ; carry set, then add 7, > w=nibble+246+7 ( note > nibble known to be a-f ) > ADDLW 0x3A ; then finally add 58 to > get 'proper' ascii > ; 1) w = > low(nibble+246+58) = 48+nibble ( if 0-9 > ) > ; 2) w = > low(nibble+246+7+58) = 55+nibble ( if > a-f ) > > CALL TX_ADD_BUFFER ; add it to tx buffer > > RETURN > > > /Tony > > > > > > Tony K|bek, Flintab AB > 22222222222222222222222222222222222222222222222222 > 2222222222 > E-mail: tony.kubek@flintab.com > 22222222222222222222222222222222222222222222222222 > 2222222222 > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu