I have seen data be written to the flash/EE data memory with ECON in assembly language but I have not been able to find any example code in C. I am unfamiliar with assembly so I am trying to learn how to write data to the flash/EE data memory in C. If anyone has any ideas on how to do this it would help greatly. thanks. - Nathan Necaise
You're using an Analog Devices "MicroConverter" of some sort? Their ECON register is just a special function register (SFR) that controls flash. There are also some address (ADRL), data (EDATAx), and timing (ETIMx) registers that go with it. Keil probably has a header file for your MCU chip (e.g., ADUC812.h) already. If not, then you can declare the SFRs in C with code like this (taken right out of ADUC812.h):
sfr ECON = 0xB9; sfr ETIM1 = 0xBA; //AR sfr ETIM2 = 0xBB; sfr ETIM3 = 0xC4; sfr EDATA1 = 0xBC; sfr EDATA2 = 0xBD; sfr EDATA3 = 0xBE; sfr EDATA4 = 0xBF;
This example, coded in 8051 assembly, would appear as: MOV EADRL, #03H ; Set Page Address Pointer MOV ECON, #01H ; Read Page MOV EDATA2, #0F3H ; Write New Byte MOV ECON, #05H ; Erase Page MOV ECON, #02H ; Write Page (Program Flash/EE)
EADRL = 0x03; // set page address == 3 ECON = 0x01; // read page 3 into EDATA1-4 EDATA2 = 0xf3; // update byte 2 ECON = 0x05; // erase page (3) ECON = 0x02; // write page with EDATA1-4
Did you look here? http://www.keil.com/download/docs/adu812_eeprom.zip.asp Jon