Saving signed integers in EEPROM?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Saving signed integers in EEPROM?

Post by jadiflow »

Hi,

I have a need to save/recall signed integers in EEPROM. Numbers are small, say between -50 and +50. The standard way to write to EEPROM is byte-based, and I add a number to each value at write, and subtract at read, to make sure they are always positive. But it is awkward and error-prone.
Is there an other more straightforward way to save/recall signed integers in EEPROM?

Edit: FC7, PIC16F886

Jan Didden
Linear Audio
Last edited by jadiflow on Wed Apr 17, 2019 10:20 am, edited 1 time in total.

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

Re: Saving signed integers in EEPROM?

Post by medelec35 »

Hi Jan,
This post might help?
Martin

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Saving signed integers in EEPROM?

Post by jadiflow »

Hi Martin, yes that surely does help, thanks. Looking at it again though, the EEPROM macro in FC7 seems to expect an INT for both the EEPROM address and the argument. Does that mean that it basically reads/writes 2-byte chunks (words) at the time, rather than bytes?

The component properties says the bit depth is 8 bit, and I can not change that afaics. So now I am confused. Do I use bytes to preset the values, and INT to read/write?

Jan

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: Saving signed integers in EEPROM?

Post by Benj »

Hi Jan,

No each write for an 8-bit device will only write the lower 8-bits of the value at the selected address. The value is a 16-bit variable to allow 16-bit writes on 16-bit devices.

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Saving signed integers in EEPROM?

Post by jadiflow »

Aha! So any INT higher than 255 I have to manipulate if I want to write it to EEPROM (on an 8 bit device). And although the macro asks for an INT address, it really can only address 256 locations then? Or does that not have that limitation?

That's OK though, that will work for me.

Jan

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: Saving signed integers in EEPROM?

Post by Benj »

Hi Jan,

It's just the data that has the 8-bit limitation on an 8-bit device. The address can be 16-bit as there are 8-bit devices with EEPROM addresses over 255.

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Saving signed integers in EEPROM?

Post by jadiflow »

Got it, thanks!

Jan

Post Reply