Moving 3.2 code to 4.0

gbathree

Active member
Hi all, we're trying to pull in some code written for Teensy 3.2 to 4.0. Honestly I'm not sure if it's going to work given the time I have.

Question 1: I looked around a bit, but wondering if anyone was maintaining a list of the areas most likely to have issues / failures when porting.

Question 2: I have one case specifically (see code below). This is a function which stores data in the EEPROM that's accessible later. I'm aware there's a lot of updates to the EEPROM library, which I can dig into also if needed.

Code:
// use this to store values to eeprom 
#define store(location, value)   { typeof(value) f = value;  if (eeprom->location != f) eeprom->location = f;  while (!(FTFL_FCNFG & FTFL_FCNFG_EEERDY)) {} }

//Example uses:
// store some info
store(shutdownTime, shutdownTemp);

// recall that info
eeprom->shutdownTime

Can anyone provide some guidance on updating this function, or use of EEPROM library generally, from 3.2 to 4.0?
 
Snippets won't compile :( ... or they could be tried.

Not used those methods as shown - but assume if they worked before then they still work.

Suggest writing a usable program and trying it or posting for others that may test if not possible there.
 
I wrote this wiki page for the unofficial Teensy wiki a few years ago:


And I wrote this post (#3) as part of another discussion:


I wrote this spreadsheet that tries to compare the pinouts of the various teensies (and other information in the other sheets):

 
Can anyone provide some guidance on updating this function, or use of EEPROM library generally, from 3.2 to 4.0?

Your macro is checking T3.x registers, so it is specific to T3.x. On T4.x, EEPROM is emulated in FLASH, and if you use the EEPROM library, your code will work on both 3.x and 4.x. The EEPROM library equivalents to your macros are put() and get(), which are templated functions that will write/read the number of bytes equal to sizeof(variable).

Code:
  EEPROM.put(offset,variable); // write sizeof(variable) bytes to EEPROM
  EEPROM.get(offset,variable); // read sizeof(variable) bytes from EEPROM

You can also use read() to read one byte, write() to write one byte, and update() to write one byte if the new value is different from the existing value.
 
Good reading joe, glossed over the register wait - indeed using the PJRC library works consistently.

Also in the past week or so looking at PJRC's EEPROM code noted it always does a read and compare of each byte before bothering to perform any update.
 
Back
Top