Hello again my friends!
I´m working with 16f877A and i have a basic question for you!
I have 2 memories (Eeprom) with adress 0x32(1byte) and 0x33(1byte) with data on it.
I have a variable V (unsigned (int), 2 bytes).
Eeprom 0x32 is MSB and Eeprom 0x33 is LSB.
How can i send 2 eeprom data into V variable
EX:
Eeprom_(0x32);---0x3;(MSB)----3 Decimal
Eeprom_(0x33);--- FF;(LSB)----255 Decimal
Variable V=03FF------1023 Decimal
thank you all, my friends.
converting data
Re: converting data
Hello marco. As with many problems in programming this has a lot of solutions which I'm going to provide you perhaps is not the best but I'm sure it works;
1. You need a single byte variable to temporarily store v value, i.e. unsigned short temp.
2. As you will first access to 0x32 memory allocation (MSB) then you have to charge it's value first, i.e. temp=V>>8; 0x32=temp;
3. Finally you charge 0x33 memory allocation value, i.e. temp=V; 0x33=temp;
1. You need a single byte variable to temporarily store v value, i.e. unsigned short temp.
2. As you will first access to 0x32 memory allocation (MSB) then you have to charge it's value first, i.e. temp=V>>8; 0x32=temp;
3. Finally you charge 0x33 memory allocation value, i.e. temp=V; 0x33=temp;
Best Regards
Omar Galicia
Mexico City
Omar Galicia
Mexico City
-
- Posts: 619
- Joined: 05 Jul 2008 06:05
- Location: Thailand
Re: converting data
In case you got confused by braus' reply, it goes like this...
Code: Select all
short temp;
int V;
V = Eeprom_Read(0x32); //temp = 0x0003
V = V << 8; //V = 0x0300, i.e. the value gets bitshifted 8 binary places to the left
temp = Eeprom_Read(0x33); //temp = 0x00FF
V = V + temp; //V = 0x03FF
Re: converting data
Hello
I haven´t try yet but it seems very logic!
Ihave compile the programme but i havent test it on hardware!
As soon as i test it ,i will comment!
Thank you my friends for the help and for que quick response.
I haven´t try yet but it seems very logic!
Ihave compile the programme but i havent test it on hardware!
As soon as i test it ,i will comment!
Thank you my friends for the help and for que quick response.
Re: converting data
Sory about the delay!!
It is working fine.
Probleme 100% solved.
Once again tank you guys.
It is working fine.
Probleme 100% solved.
Once again tank you guys.