Pages: 1 [2]   Go Down
Author Topic: Function fails with passed in variable, but works if set manually.  (Read 1784 times)
0 Members and 1 Guest are viewing this topic.
SF Bay Area (USA)
Offline Offline
Tesla Member
Karma: 135
Posts: 6783
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep.  I came up with the same fix as Pyro65, once I looked at it more carefully.
You didn't have ANY special code to read the pointers from flash...

Beats me why it worked with constants, though.  I guess the compiler did most of the pointer arithmetic at compile time, so the step where it fetched inappropriate pointers from RAM was skipped.

Des Moines, Iowa, USA
Offline Offline
Jr. Member
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I really believe it's a compiler issue.

Because your flasharray is an array of progmem pointers, not data. You must use pgm_read_word to retrieve the pointer.


This is reading the i'th value in sram, you placed the data in PROGMEM. I can see that it works on occasion for you ( and my test ), but it is still wrong.

Yes, agreed, and understood. That's what I pointed out I do in my production code (see my post from April 10, 2013).

My issue was not with that, at all,, but with the inconsistency I see with things being done behind the scenes with the compiler and preprocessor and such. I really expect I am doing more intense stuff than probably 99% of most Ardunio uses ever deal with smiley  It's fun.

The challenge I faced was making code that could generate to use RAM or FLASH by altering a #define, to make it easy for end-users that do not get involved with how the tools work.

Embedded Software Engineer
UNO | Leonardo | Due | Teensy | BASIC Stamp

Pages: 1 [2]   Go Up
Jump to: