AnsweredAssumed Answered

How can I write to EEPROM using bootloader ?

Question asked by Jonathan Chouinard on Jul 23, 2016
Latest reply on Aug 30, 2016 by Jonathan Chouinard

(Sorry for my English)

 

Hello,

I'm using a MC9S12DJ128 MCU and I want to write in the 2k EEPROM. By searching a lot on the internet, I managed to do what I wanted, but not the way I wanted... I'm currently writing in the EEPROM by using theses commands in codewarrior (found in the UNSECURE command file):

 

reset

wb 0x03c 0x00       //disable cop

wait 20

wb 0x110 0x09      // set ECLKDV clock to 2Mhz

wb 0x114 0xFF      // EPROT all protection disabled

wb 0x115 0x30     // clear PVIOL and ACCERR in ESTAT register

wb 0x112 0x00     // clear the WRALL bit in FTSTMOD

wb 0x115 0x02

ww 0x118 0x002E   // write to EADDR eeprom address register

ww 0x11A 0x0000  // write to EDATA eeprom data register

wb 0x116 0x60       // write SECTOR MODIFY command in ECMD register

wb 0x115 0x80       // clear CBEIF in ESTAT register to execute the command

wait 20

 

Now, I want to do the same thing WITHOUT using the BDM port. I will run the code in a bootloader, and it needs to be in assembly. This is what I've done so far, but it's not working:

 

MOVB   #$00,$003C

MOVB   #$09,$0110

MOVB   #$FF,$0114

MOVB   #$30,$0115

MOVB   #$00,$0112

MOVB   #$02,$0115

MOVW  #$002E,$0118

MOVW  #$0000,$011A

MOVB   #$60,$0116

MOVB   #$80,$0115

 

I don't know how to do a reset in assembly, maybe that's the problem... Or maybe the timings are wrong...? (I'm a complete beginner in assembly). Please help me !

 

Thanks

Outcomes