Firstly, I'm sorry if my English is not good enough to describe the problem more clearly
I'm using Mega2560 with MPU9250 sensor to develop my algorithm. Now I have to move my algorithm to Tiva C because Tiva C has Can bus peripheral. When I do that, I dont understand that what PROGMEM definitions used for? As I know that PROGMEM is involved with AVR memory, which means I isn' t suitable to use with Tiva C. So what it is really used for? What should I do with these definitions when move my code to Tiva C? Please help me
Because it runs on Tiva boards, which seems to be a new development board format from Texas Instruments. Roughly looks like the same capability as a Teensy 3.x in a size about the same as an Uno.
There are probably good reasons to choose the Tiva. Obviously direct library compatibility with Arduino is not one of them.
"Tiva C" is the TI's name for a group of microcontorllers, not a "language." Like in TI DevTools I don't know why TI chose such an ambiguous name. I don't know why they gave up "Stellaris." Sigh.
I know that PROGMEM is involved with AVR memory, which means I isn' t suitable to use with Tiva C. So what it is really used for? What should I do with these definitions when move my code to Tiva C?
Because of AVR's "Harvard architecture", you need to take special steps (PROGMEM) to store "data" in the flash memory, and more special steps (pgm_read_xxx) yo access data that has been put in flash. Otherwise, you could only put program instructions in flash. The ARM has a different architectures, and data can be put in flash, or accessed from flash, just like any other data. The compiler only needs to see the declaration "const" to know that the data won't be modified, and is therefore OK to put in flash instead of RAM. (this IS a compiler dependency; it could be different with another compiler.)
By continuing to use PROGMEM statements in the program, and pgm_read_xxx() function calls to access the data, you accomplish two things:
You make it really OBVIOUS to anyone reading the code that the data is in flash memory and is not quite normal data (it can't be written.)
You make the code "portable" to other architectures that DO need some sort of special handling to access flash data (like the AVR, but potentially other chips as well.) All you have to do is make the PROGMEM and pgm_read_xxx() statements do "the right thing", which is usually easily accomplished using C pre-processor macros.
The macros defined for the Tiva chips are typical for a chip that doesn' need any special processing:
#define PROGMEM /* empty - PROGMEM simply disappears */
#define pgm_read_byte(x) (*(x)) /* pgm_read_xxx() via a ptr is just dereferencing the pointer. */
#define PSTR(STR) STR /* A string in PROGMEM is the same as a normal string. */