How do I read from flash

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 I can't find function to read from flash or from EEPROM? Whish function can I use to red the data from a particular addresss?

0 Likes
7 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

There is no API. Datasheet says:

   

   

   

There is no need of APIs to read from the EEPROM. The entire content of the EEPROM is

   

mapped into memory space and can be read directly. EEPROM allows read access at the byte

level. The following defines are used for reading EEPROM:

   

   

Sorry, cut and paste does not work correctly with this crippled forum software, look at Datasheet pg. 2.

   

Some hints: declare a structure for your EEProm data and a pointer to it. Assign CYDEV_EE_BASE to the pointer and access the structire indirectly.

   

Put two additional datafields for housekeeping into the struct: a "magic number" indicating that EEProm is programmed and contains valid data and a version byte which might come in handy after some time of product evolve.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Does Cy_GET_REG8() work. Because the flash has row width of 256bytes. Can we not read just a byte from flash??

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Cy_GET_REG8() is used to access registers in SRAM.

   

 

   

Bob is correct, use a pointer, init it to CYDEV_EE_BASE,

   

and supply an offset to get to the particular byte/word/long

   

you are trying to access.

   

 

   

unsigned int * pTr = CYDEV_EE_BASE             //Init point to start of EEPROM

   

unsigned int getmydata, offset;

   

........

   

getmydata = *( pTr + offset );                               // Offset is added to pointer to get to specific data

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

It has never (not yet) been standarized in C-language how to access a variable directly from which the physical address is known. There is a construct like _at_ in keil, nothing good to work with in GCC so the only thing left is a pointer which is assigned the address to.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I know it's an old thread, but I used the search function and this is relevant to my interest.

I want to save the software version in the flash section of the memory (not the eeprom) and I was wondering how I should access it, and where exactly I should put the offset to. I have a bootloader in my project and I don't want my software version to be overwritten by the bootloader or vice-versa.

How should I do this? I started reading on the _at_ keyboard but I still get memory overlapping warnings (which doesn't seem like a good thing to me).

Thanks!
 

   


 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Easiest would be to declare

   

static const uint16 VersionNumber = 0xCoffee;

   

This will be placed into flash and you may access it like any other variable.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

This might be useful as well -

   

 

   

http://www.cypress.com/knowledge-base-article/psoc-3-psoc-4-and-psoc-5lp-flash-memory-organization-a...

   

 

   

Regards, Dana.

0 Likes