Blocking read/write from internal EEPROM and Flash

Status
Not open for further replies.

nelsongoncalves

New member
Hello,

I have a Teensy 3.1 and I would like to read immutable data from the uC Flash and read/write to the internal EEPROM.
The performace, e.g. how fast/read operations execute, is not important for me, only if the operation is implemented using a blocking wait.

I was looking through the source code, and only the only place where there are blocking waits is when writing to EEPROM.
Reading from Flash or from EEPROM has no blocking wait, although it is probably slower than reading from RAM. Is this correct ?

Also, to have a constant placed in flash is it enough to declare it "const" or do I need the PROGMEM macro:

Code:
static const uint8_t ConstantValue = 0x12;    // this is enough to place ConstantValue in the uC flash ? 

static uint8_t ConstantValue PROGMEM = 0x12; // or should I use PROGMEM

Thanks in advance,

Nelson
 
Not quite sure what you really want to ask, but I see 2 specific questions, so I'll try to answer those.


Reading from Flash or from EEPROM has no blocking wait, although it is probably slower than reading from RAM. Is this correct ?

Reading from RAM takes 2 cycles, or only 1 cycle if the previous instruction is a "related" read.

I believe flash reads are single cycle if the is already in the cache. But the cache is tiny, I believe only 256 bytes. The flash runs at 24 MHz, so if your CPU is at 96 MHz a cache miss could take a few extra cycles.

I don't know how fast EEPROM reads are. I've never really worried about it. The FlexNVM does use a RAM buffer, so you're reading from RAM which is quick. But the read is done over a peripheral bridge, so there might be extra cycles there. But it's not anything like accessing a slow off-chip resource.


Also, to have a constant placed in flash is it enough to declare it "const" or do I need the PROGMEM macro:

Yes, on Teenst 3.x you only need const. On Teensy 4 we do use PROGMEM, and the speed differences are very different because the flash is a separate chip, but the CPU has 2 large caches.

And FWIW, Teensy 3.1 was discontinued many years ago....
 
Hello Paul,

Thanks for the quick reply. I am working on developing a cooperative embedded OS, and so it was important for me that read/writes from/to EEPROM
had no significant waiting times. The same for reading from Flash. Had they existed, I would have need to take them into account and force switching to another task.
In this case, since I am not too much concerned with performance, I can treat read/write operations are being fast enough.

Regarding the Teensy 3.x being discontinued, these are leftovers that had lying around. I want to compare the embedded OS across multiple small embedded platforms,
and the Teensy was the easiest to start with.
 
Status
Not open for further replies.
Back
Top