Is there code ready-to-use for EEPROM emulation on AW32??

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there code ready-to-use for EEPROM emulation on AW32??

1,599 Views
fjrg76
Contributor IV
Hi!!

Is theresome ready-to-use code for the the EEPROM emulation on AW32 for the CodeWarrior in C??

I tried QG8 flash 6.zip for the QG8 and it works, but when ported to the AW32 it works erraticaly: sometimes it writes on the flash, other times it hangs, other losts its tracks, and so on. Actually it works pretty well once. In the .prm file I've located two banks

EEPROM0                      =  READ_ONLY    0x8000 TO 0x81FF;
EEPROM1                      =  READ_ONLY    0x8200 TO 0x83FF;
ROM                      =  READ_ONLY    0x8400 TO

Besides, when I try to run it inside the main() function it may works, however, when executed inside some other function it returns to the RAM space and you can imagine the mess.

If I don't make this thing to work soon, I will need to add some eeprom chip into my project =(

Do I miss something ?? Is there any code around??

Thanks!!
Labels (1)
0 Kudos
4 Replies

328 Views
RickN
Contributor I
Hi,
 
   You can also use Processor Expert, the rapid application development tool included in CodeWarrior, to generate the C code for EEPROM emulation in Flash memory.  It works well on the 9S08AW, and runs on the stack, so you don't have to mess with .prm files.  The Processor Expert Bean is called intFlash, and comes with the Professional Edition of CodeWarrior for MCU v6.x.  You can get an evaluation license for CodeWarrior, and test the intFlash bean.  Processor Expert generates C code, so you can generate a test project to evaluate the intFlash bean, and then port these routines over to your application.  You can also purchase just the intFlash bean, if you don't need everything included in the Professional Edition of CodeWarrior.  
 
   Thanks,
 
    Rick
 
0 Kudos

328 Views
bigmac
Specialist III
Hello,
 
My understanding is that the code you have adapted uses a fixed block of low RAM for running RAM based functions associated with the emulation.  If your AW32 project uses any global variables located within Z_RAM, it might be possible for these to over-write the function code, or vice versa.
 
For the QG8 version, I see that the start address of the Z_RAM segment has been increased (but probably by an insufficient amount), presumably to prevent what I have just described.  Have you done a similar thing for your AW32 project?  I think you will need to allow 80 bytes, rather than 64 bytes.
 
Regards,
Mac
 
0 Kudos

328 Views
fjrg76
Contributor IV
Hi Big!!

In the .prm file of the QG8 flash6 there is an instruction "RELOCATE_TO 0x0060. This is the complete prm for such a project

/* This is a linker parameter file for the QG8 */

NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */

SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
    EEPROM                   =  READ_ONLY    0xE000 TO 0xE1FF;
    ROM                      =  READ_ONLY    0xE200 TO 0xFFAD;
    Z_RAM                    =  READ_WRITE   0x00A0 TO 0x00FF;
    RAM                      =  READ_WRITE   0x0100 TO 0x025F;
    ROM1                     =  READ_ONLY    0xFFC0 TO 0xFFCF;
    CODE_RELOC               =  READ_ONLY    0xe200 TO 0xe240 RELOCATE_TO 0x0060;
END

PLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */
    DEFAULT_RAM                         INTO  RAM;
    DEFAULT_ROM, ROM_VAR, STRINGS       INTO  ROM; /* ROM1 In case you want to use ROM1 as well, be sure the option -OnB=b is passed to the compiler. */
    _DATA_ZEROPAGE, MY_ZEROPAGE         INTO  Z_RAM;
END

What is he trying to do relocating the code at that location?? Should I do the same in the same places, or should I change them according to my project?? But for that first I need  to understand what they do =)

None of my globals are located in Z_RAM. What can I do in order the routines not to use low ram but normal (> 0x100)??

Ill try to make bigger space for the routine to see what happens.

Thanks and more advices are welcome =)
0 Kudos

328 Views
fjrg76
Contributor IV
I understood it!!

CODE_RELOC               =  READ_ONLY    0x8687 TO 0x86cc RELOCATE_TO 0x0070;

0x8687 is the start address of the EraseFlash() function
0x86cc is the last address of the same function
0x0070 is the start of the Z_RAM for the AW32

Now it seems to work when tracing step by step. When running at full speed it losts somewhere.

I'll keep trying!!

Also the interrupts must be disabled when performing erase or write tasks:

    InitFlash();                                //set up for erasure programmig

   
    llenaMem0();

    DisableInterrupts;
    if (CopyErase(&EepromPage1) == !OK)                     //copy routine and erase the EEPROM
        Error(ERASEERROR);
    EnableInterrupts;

    CopyProgram();                               //copy routine

    for(i=0;i<18;i++){
        DisableInterrupts;
        if (RunProgram(&EepromPage1+i,buf.str[i]) == !OK)        //write one byte in EEPROM
            Error(PROGERROR);
        EnableInterrupts;
           
    }



Message Edited by fjrg76 on 2008-02-07 06:32 AM
0 Kudos