@@ -160,6 +160,38 @@ describe('EEPROM', () => {
160160 expect ( eepromBackend . memory [ 15 ] ) . toEqual ( 0x55 ) ;
161161 expect ( eepromBackend . memory [ 16 ] ) . toEqual ( 0xff ) ;
162162 } ) ;
163+
164+ it ( 'should write two bytes sucessfully' , ( ) => {
165+ const cpu = new CPU ( new Uint16Array ( 0x1000 ) ) ;
166+ const eepromBackend = new EEPROMMemoryBackend ( 1024 ) ;
167+ const eeprom = new AVREEPROM ( cpu , eepromBackend ) ;
168+
169+ // Write 0x55 to address 15
170+ cpu . writeData ( EEDR , 0x55 ) ;
171+ cpu . writeData ( EEARL , 15 ) ;
172+ cpu . writeData ( EEARH , 0 ) ;
173+ cpu . writeData ( EECR , EEMPE ) ;
174+ cpu . writeData ( EECR , EEPE ) ;
175+ eeprom . tick ( ) ;
176+ expect ( cpu . cycles ) . toEqual ( 2 ) ;
177+
178+ // wait long enough time for the first write to finish
179+ cpu . cycles += 10000000 ;
180+ eeprom . tick ( ) ;
181+
182+ // Write 0x66 to address 16
183+ cpu . writeData ( EEDR , 0x66 ) ;
184+ cpu . writeData ( EEARL , 16 ) ;
185+ cpu . writeData ( EEARH , 0 ) ;
186+ cpu . writeData ( EECR , EEMPE ) ;
187+ cpu . writeData ( EECR , EEPE ) ;
188+ eeprom . tick ( ) ;
189+
190+ // Ensure both writes took place
191+ expect ( cpu . cycles ) . toEqual ( 10000004 ) ;
192+ expect ( eepromBackend . memory [ 15 ] ) . toEqual ( 0x55 ) ;
193+ expect ( eepromBackend . memory [ 16 ] ) . toEqual ( 0x66 ) ;
194+ } ) ;
163195 } ) ;
164196
165197 describe ( 'EEPROM erase' , ( ) => {
0 commit comments