EEPROM emultaion on QY4 in C

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

EEPROM emultaion on QY4 in C

3,279 Views
jag
Contributor IV
Hi,
I need to make my program to save in flash some parameter (in fact only 1 byte). I've seen Application Note AN1831.pdf, but it's in assembler and I don't like assebler :smileytongue:.
So the question is there is someone that has some routines written for a program coded in C (some inline assembler is good too)

Thanks Bye Jack
Labels (1)
0 Kudos
7 Replies

455 Views
Alban
Senior Contributor II
Hello Jack,

There is little space on the QY4. That is why the routines are already integrated in ROM.
I think it is worth you looking at how to use inline assembly.
This subject has been talked about a few time and shows how to easily mix an ASM call in C.

For this, search from "asm {" in the forum search below.
I answered the same question last night :smileywink:

You need to suffer to be efficient :smileyhappy:

Cheers,
Alban.
0 Kudos

455 Views
jag
Contributor IV
Hi,
thanks for the answer.
I'll look for inline assembly (I already did some inline assembly, but not for this processor).

Another question:
I've found these two files:

HC908_HIS_Flash_Driver_v1.3_7-14-04.zip
HC908SGF50NVMSSD.zip

that seems to be a sort of library for writing the flash. But I don't understand the difference and which use with the QY4 (if the case).

Thanks Bye Jack
0 Kudos

455 Views
Alban
Senior Contributor II
Well found Jack,

These files are more appropriate for larger flash.
I mean as soons as you add driver layers, you use more and more memory.

Even if the principle does work on the QY4, because that is a 0.5µm Split Gate Flash, I would not advise you to use these as the AN1831 is really a perfect reference and will make you save precious Bytes of flash :smileyhappy:

I hope I'm clear enough,
Alban.
0 Kudos

455 Views
jag
Contributor IV
Update:
I've found application note AN2346/D that seems to be better for the QY.
The rproblem is that they are in assembler too :smileysad:
Anyway, I've a question on inline assembly:

void foo(void)
{
  asm{ nop}
}

and another function

void bar(void)
{
    asm{
   
    //here I need to call foo()

    }
}

How can I call foo() inside the asm{} block in bar() ?

Thanks Bye Jack

PS: If someone has already the routine from AN2346 wrapped for a C program and want to share with me I'll pay a beer the first time we meet :smileywink:

0 Kudos

455 Views
bigmac
Specialist III
Hello Jack,


jag wrote:

void foo(void)
{
  asm{ nop}
}

and another function

void bar(void)
{
   asm {
   //here I need to call foo()
   }
}

How can I call foo() inside the asm{} block in bar() ?


The following should work for CW - other compilers may differ.

     jsr  foo
 
Of course, the situation becomes more complex if the function has any input parameters, or returns a value.
 
Regards,
Mac
 
0 Kudos

455 Views
jag
Contributor IV
Hi,
thanks. I've found a solution :smileyhappy:


Bye Jack
0 Kudos

455 Views
bigmac
Specialist III
Hello Jack,
 
The attached code was originally developed from AN2346, but was considerably simplified.  The assembler form has been in use for a number of years.  The attached files attempt to provide a C wrapper for that code.
 
The simplified code assumes that non-volatile parameter data need not be written very frequently, so flash wear out will not be an issue.  The code erases the first page of flash (64 bytes), and then programs data to the first row (32 bytes) only.  The data may consist of 1 to 32 bytes, and is always programmed from the start of the row.
 
Note that the PRM file must also be modified so that code is never allocated to the first flash page, and that the global buffer structure in RAM, required to be at a precise location, is not overwritten by any other global variables.
 
Regards,
Mac
 


Message Edited by bigmac on 2007-07-11 01:13 AM
0 Kudos