What's the difference between pgm_read_word()/_near()/_far() for arduboy? / progmem confusions

My brain generally gets a bit confused when thinking about them - when is it good to use one rather than another? (specifications are here - http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html#gaf51eeaa847dd2668d2a66b70ecfb7398 )

The arduino docs on PROGMEM sometimes use pgm_read_word and sometimes use pgm_read_word_near?

Are they all the same because everything on an arduboy can be accessed with a 16-bit address?

Waait I didn’t read closely enough: read_word is literally defined to be read_word_near in the avr specs.

But the arduino documentation for progmem uses one sometimes and one another - but there must be a difference on some other arduino chipsets? Or maybe it’s just inconsistent documentation :stuck_out_tongue:

I believe far functions are only required if the data resides in flash addresses past 64KB. Since the Arduboy’s processor only has 32KB total flash, you can always use near with it.

2 Likes