EEPROM Storage

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

Moderators: Benj, Mods

Gnu
Posts: 20
Joined: Mon Apr 16, 2007 6:59 pm
Location: UK
Contact:

EEPROM Storage

Postby Gnu » Thu Jan 10, 2008 7:01 pm

Is it possible to store the 10-bit output from the ADC in a 16F88 in its EEPROM, using Flowcode, perhaps by storing 5 bits in two separate locations ? If so, what is the neatest way of getting the number out again ?

Regards

IRH

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

Postby Benj » Fri Jan 11, 2008 10:25 am

Hello

The easiest way is to use a full two bytes. eg 16-bits.

Firstly you will have your 16-bit integer variable, we will call this int_var.

So to convert int_var into two bytes we do the following.

byte1 = int_var
byte2 = int_var >> 8

The two bytes can now be written to the EEPROM or the RS232 etc.

To convert the number back simply reverse the calculations.

int_var = byte1
int_var = int_var + ( byte2 << 8 )
These users thanked the author Benj for the post:
George_B (Fri Dec 25, 2015 12:49 pm)
Rating: 5.26%
 

Gnu
Posts: 20
Joined: Mon Apr 16, 2007 6:59 pm
Location: UK
Contact:

Postby Gnu » Fri Jan 11, 2008 10:36 am

Thanks Ben.

Regards

Gnu