EEPROM data bit size

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

EEPROM data bit size

Post by echase »

On the 16F690 the EEPROM appears to accept 14 bit numbers with the number being split across two 8bit registers. The datasheet is not that clear on this. Can Flowcode use a normal 16 bit variable to enter these numbers as all the help file examples only quote up to 8 bit numbers? If I limit my number size to 14 bits will it work? I assume the EEPROM can not accept negative numbers.

I put this same question in the v5 section as I might be using v5 instead, depending on the project worked on. Are v3 and v5 any diffent in this respect?

An alternative is some C code to do it, but beyond me to write it.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: EEPROM data bit size

Post by kersing »

Data EEPROM is just 8 bit, Program EEPROM/Flash is wider.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Re: EEPROM data bit size

Post by echase »

Ah thanks, that claries the datasheet. I will have to divide all my values by 8 or 16 before writing them and multiply again when reading them.

Interesting that Flowcode (at least v3) produces no error message if compile using an INT variable for the data for the EEPROM. That could lead to someone inadvertantly trying to store a number >255.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: EEPROM data bit size

Post by medelec35 »

Martin

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Re: EEPROM data bit size

Post by echase »

Thanks. In the past I found it worked fine if I used an integer variable if I limited my integers to >=0 and <256. But I have now extended the routine to store more values in more EEPROM locations and find it is giving unusual answers when read back. Could this be because it does not consistently store integers even if limited to 256? Or reads back the stored byte to the integer variable incorrectly?

I could just save the integers to byte variables before storing them and same again upon reading, but am getting preciously short of programme space so trying not to have unnecessary lines.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: EEPROM data bit size

Post by medelec35 »

Hi echase,
Perhaps if you could post the flowchart that is returning strange values.
I have successfully stored and retrieved values from 0 to 32767 in 8bit EEPROM by converting int to bytes first.

Martin
Martin

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Re: EEPROM data bit size

Post by echase »

To be clear I am doing this by storing the integer variable straight into EEPROM. i.e. Write, location, integer variable. And Read , location, integer variable. I am hoping that as the top 8 bits of the integer will always be zeros due to limiting data to 256 Flowcode can cope with putting an integer into an 8 bit data space with no extra processing by me.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: EEPROM data bit size

Post by kersing »

Could you try ANDing the value read from eeprom with 255? To do this, just after reading a value add a calculation icon:

Code: Select all

yourvar = yourvar & 255
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Re: EEPROM data bit size

Post by echase »

My stupidity it seems. I was manipulating the variables incorrectly. It does seem that one can read and write to an integer variable so Flowcode must be truncating the top 8 digit of treh variable when writing. But still getting the odd funny result.

Post Reply