Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).
|
Hello All, I have written an assembly routine to write one byte to the EEPROM of the MC9S12DP256. The routine is called with the destination address in the index register and the data in REG A. Since the "EEPROM" on the MC9S12DP256 is a small sector FLASH this requires making a copy of the destination aligned sector in RAM, changing the required byte and rewriting the four byte RAM buffer to EEPROM. I understand that the sector in EEPROM is first erased and the two aligned words are written. My problem is that the subroutine works fine the first time I call it but fails the second time; the third time the routine is called it works but not the forth and so on. It doesn't matter if I am writing sequential bytes or random bytes within the EEPROM area. Has anyone else had similar problems with the Command State Machine of the MC9S12DP256? Roger Schaefer http://www.ezl.com/~rsch/ |
|
|
|
Hi Roger, You must program an aligned word to the EEPROM of the DP256. Attempting to program a misaligned word or a byte will cause an ACCERR error. This is explained in the EETS4K block guide Section 4.1.4. David --- In , "Roger Schaefer <rsch@e...>" <rsch@e...> wrote: > Hello All, > > I have written an assembly routine to write one byte to the EEPROM of > the MC9S12DP256. The routine is called with the destination address > in the index register and the data in REG A. Since the "EEPROM" on > the MC9S12DP256 is a small sector FLASH this requires making a copy > of the destination aligned sector in RAM, changing the required byte > and rewriting the four byte RAM buffer to EEPROM. I understand that > the sector in EEPROM is first erased and the two aligned words are > written. > > My problem is that the subroutine works fine the first time I call it > but fails the second time; the third time the routine is called it > works but not the forth and so on. It doesn't matter if I am writing > sequential bytes or random bytes within the EEPROM area. > > Has anyone else had similar problems with the Command State Machine > of the MC9S12DP256? > > Roger Schaefer > http://www.ezl.com/~rsch/ |
|
Hi, I found my problem; it was not that I was writing to non-aligned words or not setting flags in the correct order but rather it was a problem with my main program. It was writing to the EEPROM area and reading back the same location to check if it was RAM or ROM. This started the State Machine. The solution was to write a couple of instructions at the beginning subroutine to write a zero to ESTAT then clear the error flag of ACCERR. Hope this helps someone else. Roger --- In , "Roger Schaefer <rsch@e...>" <rsch@e...> wrote: > Hello All, > > I have written an assembly routine to write one byte to the EEPROM of > the MC9S12DP256. The routine is called with the destination address > in the index register and the data in REG A. Since the "EEPROM" on > the MC9S12DP256 is a small sector FLASH this requires making a copy > of the destination aligned sector in RAM, changing the required byte > and rewriting the four byte RAM buffer to EEPROM. I understand that > the sector in EEPROM is first erased and the two aligned words are > written. > > My problem is that the subroutine works fine the first time I call it > but fails the second time; the third time the routine is called it > works but not the forth and so on. It doesn't matter if I am writing > sequential bytes or random bytes within the EEPROM area. > > Has anyone else had similar problems with the Command State Machine > of the MC9S12DP256? > > Roger Schaefer > http://www.ezl.com/~rsch/ |