EEPROM LookUp Table problem with ATMega328

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Niro
Posts: 77
Joined: Mon Jan 03, 2011 8:58 pm
Has thanked: 29 times
Been thanked: 10 times

EEPROM LookUp Table problem with ATMega328

Post by Niro »

Dear all,

i tried to add an LookUp table (array of 10 bytes) to the eeprom of my ATMega328 within the supplementary code like this:

uint8_t LUT[10] EEMEM = {0,1,2,4,8,12,16,20,50,100}; //Table with 10 data points

I declared an byte array LUT[10] in FlowCode via the variable manager (in C it appears as 'volatile char FCV_LUT[10]' ).
Then I added the following C-code at the top of the main routine to read the EEPROM-data into the LUT[] ram variable :

int i=0;
for(i=0; i <= 9; i++)
FCV_LUT=eeprom_read_byte(&LUT);

Now I displayed all the 10 LUT numbers on my EvaBoard and all values are '255'.

So it doesn't seem that my procedure is working...
Can anbody help?

Many Thanks,
Niro

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: EEPROM LookUp Table problem with ATMega328

Post by Benj »

Hi Nero,

I think your code is working but the values have not made it from Flowcode into the device. You can confirm this by writing a value to the EEPROM using the EEPROM write function and then using your existing readback function to confirm the data has gone in.

AVR's seem to generate separate hex files for the data and the EEPROM contents though this seems daft to me.

I'm sure there is a way of doing it by editing the compilation batch file and the programmer batch file to include the extra EEPROM file though this may not be straightforward. One workaround is to write the values into EEPROM at the start of your main function.

Niro
Posts: 77
Joined: Mon Jan 03, 2011 8:58 pm
Has thanked: 29 times
Been thanked: 10 times

Re: EEPROM LookUp Table problem with ATMega328

Post by Niro »

Hi Benj,

you are right.
The data hasn't been written into the eeprom with the command: "uint8_t LUT[] EEMEM = {0,1,2,4,8,12,16,20,50,100}; //Table with 10 data points".
Using the 'normal' eeprom write command within FlowCode it is written all well.
But the problem is, I don't want to write it into the eeprom everytime the programm on the AVR is runnig.
It just needs to be written once the controller is programmed.
After spending lots of hours trying to find the right answer, for me there seems to be only one practical (??) workaround....

Generating a new project on AVR-Studio with the following C-code:

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>

uint8_t LUT[] EEMEM = {0,1,2,4,8,12,16,20,50,100}; //Table with 10 data points

int main(void)
{
return 0;
}


...and building it, an *.eep file is generated, which contians the following data:

:0A00000000010204080C1014326421
:00000001FF


This seems to be the right file (Intel hex-format) to be programmed to the eeprom with only the AVR-Studio.

Do you know a way, how to add the right starting-adress to the C-code and maybe how to generate this file with FlowCode automaically, like it is done with AVR-studio?

Many thanks,
Niro

Post Reply