Roland, Before you return from the subroutine, you don't restore RP0 to point back at Bank 0. I suspect that this is your problem. myke >Hello everyone! > >I would be very grateful if someone could look through the following >snipped of code and check for any obvious mistakes. >I am basically trying to write values to consecutive byte in eeprom >data memory, starting at address 0. >My problem is that the program seems to get stuck waiting for the >write to finish. I have checked and double checked all register >and bit location declarations. > > > >;=== Procedure init_eedata === >init_eedata > movlw 0 > movwf eeadr > > movlw .126 > call write_eedata > movlw .48 > call write_next_eedata > movlw .109 >; etc >; etc > > return > >;=== Procedure write_eedata === >; Procedure expects the data to be written in w and the address in >; eeadr >write_next_eedata > incf eeadr, same ; go to next address > >write_eedata > movwf eedata ; data to be written > bsf eecon1, wren ; enable writes to data eeprom > bsf status, rp0 ; bank 1 > bcf intcon, gie ; no interrupts > movlw 55 ; taken directly from databook > movwf eecon2 > movlw h'aa' > movwf eecon2 > bsf eecon1, wr ; start write >; bsf intcon, gie ; enable interrupts >; Commented out because I am not using >; interrupts > bcf eecon1, wren ; disable eedata writes >writing > btfss eecon1, eeif ; wait for write to finish > goto writing > bcf eecon1, eeif ; clear eeprom interrupt flag > > return > >Thanks > Roland > > "Some people say that foreign cars handle best, while others say domestic. For my money, nothing handles as well as a rental car." - P.J. O'Rourke