Might there be a bug at the EEPROM write simulator in ATMEL/Microchip Studio?
I'm currently writing an assembler program for the ATMEGA328P, using Microchip Studio (7.0.2594) and also a test suite in order to verify correct funtioning. While testing this program writing error log records to EEPROM I encountered a strange error. I'm using the standard ATMEL proposal to do so:
EEPROM_write:
; Wait for completion of previous write
sbic EECR,EEPE
rjmp EEPROM_write
; Set up address (r18:r17) in address register
out EEARH, r18
out EEARL, r17
; Write data (r16) to Data Register
out EEDR,r16
; Write logical one to EEMPE
sbi EECR,EEMPE
; Start eeprom write by setting EEPE
sbi EECR,EEPE
ret
For the first few calls things go smoothly - but in the 9th call strange things happen:
- first: while passing the initial two instructions immediately during the first 8 WRITEs at the 9th call suddenly the EEPE bit seems to indicate a WRITE operation ongoing (which is actually correct!) BUT WHY did the simulator not stop in the 8 calls before?
In particular I'm astonished to see that it's always in the nineth call from program start where this is happening - no matter what I do before or where this 9th call is placed.
- second: After the end of this waiting loop the program continues at some fantasy location but not at all at the third instruction of EEPROM_write. Why?
- third: It doesn't make any difference whether I go through the program by single stepping (which means about 3000 clicks! brrrr!!!) or by setting breakpoints.
May I ask the authors of the ATMEL simulators or any other "connaisseur" of the STUDIO if my observations are correct or if I am hunting any phantoms? And - of course - any help to correct the situation would be warmly appreciated!