On Mon, 25 Feb 2002 12:51:58 -0700, Tim Crist wrote: >Okay, I'll try this again... > >To read from my EEPROM inside the 'F628 I put the desired EE address in = w >and call 'ReadEE' (see code snippet). > >I'll confirm the value in address 0x00 of the EE space equal to 0xAA, = and >address 0x01 equal to 0x55 by looking at the EEPROM memory window. If I= run >at 4Mhz and read the two addresses one after the other, 'ReadEE' sends = back >0xAA each time. If I step through the program using the ICE2000, I'll = get >the correct values: 0xAA, and 0x55. What gives? > >ReadEE > BANK1 > movwf EEADR ;Address to read > bsf EECON1,RD ;EE Read > movf EEDATA,w ;w =3D EEDATA > BANK0 > return > I ran into something that might be similar in the 16C745's UART. I wanted to send the same character 4 times as fast as I could. The '745 runs at 24MHz. If I used the following sequence, some of the bytes wouldn't transmit. movlw 'A' movwf TXREG ; write it btfss PIR1, TXIF ; TXREG empty? goto $-1 ; no, wait until it is movwf TXREG ; else write it again btfss PIR1, RCIF goto $-1 movwf TXREG btfss PIR1, TXIF goto $-1 movwf TXREG I could never get all four bytes sent. Usually two or sometimes three came across. I ended up having to insert a NOP between each "movwf TXREG" instruction and the "btfss PIR1, TXIF" following it.=20 I suspect that there's a race condition between the PIR1 status bit and the TXREG. Since you'd normally be changing w before writing TXREG again anyway, you can burn that cycle by reloading w before you test the PIR1 bit. Placing a NOP between the bsf and the register read may cure your problem. (Don't forget, the bsf does its write in the last Q cycle of an instruction. Even at 4MHz, that's not much time before the read occurs.) Regards, Bob -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu