(Note: This was recently posted to the Microchip PIC WebBoard. Sorry if = you've read it there as well.) OK, I'm looking to write several bytes of data to the EEPROM quickly. = Here's the code: ; Initialize data fields needed movlw data movwf FSR movlw 5 movwf scratch clrf EEADDR ; Start with addr 1 wrt_et incf EEADDR,F movf INDF,W movwf EEDATA wrt_wt =20 bsf GPIO,LINE1 bcf GPIO,LINE1 call WRITE_BYTE btfss PC_OFFSET,7 goto wrt_wt bsf GPIO,LINE2 bcf GPIO,LINE2 incf FSR,F decf scratch,F btfss STATUS,Z goto wrt_et Quick summary: FSR is pointing to the beginning of five bytes of data. = LINE1 and LINE2 are two I/O pins just for debugging access time. All data locations = are properly declared, and TRIS bits are correct for LINE1/2. Vcc is 4.0 V = (+/- 0.1V). OK. The original example of the Flash51x code for a byte write is as = follows: Example 1: Write a byte to EE Data memory MOVLW 0x05 MOVWF EEADDR ; Set EE Data Address MOVLW 'A' MOVWF EEDATA ; Set EE Data CALL WRITE_BYTE ; initiate write BTFSS PCOFFSET,7 ; was command accepted? GOTO NOWRITE ; Command rejected... Now, they don't give any examples for what NOWRITE is, or where it goes. = From what I figured, if a write command failed, I want to try it again until it = does. OK, here's the problem: It's taking long than expected to write a byte. = WRITE_BYTE takes approx 2.5 ms at our clock rate. The data sheet (DS40139E) states = that it can take up to 4 ms for the write to finish. So, from my estimate, 6.5 = ms/byte is the max time, and I'm looking at 9 to 10 ms of write time. Here's some timing info: BYTE1: LINE1 toggles. LINE2 toggles approx. 7.5 ms later. BYTE2 through 5: LINE1 toggles right after previous LINE2. LINE1 toggles again approx. 2.5 ms later. LINE2 toggles approx. 7.5 ms later. Does everyone else call the WRITE_BYTE routine immediately again after a = write failure? Right now, I could wait 4 ms default after each call, but I'd = hate to waste time if I don't need to wait. Another question is: what is the code doing = during this 7.5 ms? I'd expect the code to try to write a byte every 2.5 ms, = constantly, until it was taken. I didn't see any while loops in the MChip flash51x.asm= code. Anyone have any idea, or am I the only one on this Conference that needs = the minimum write times possible and the only one to have timed the writes? John -- John Patrick Software Engineer - Job Competitive Robotics - Hobby -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu