Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 22, 2024, 01:03:34 01:03


Login with username, password and session length


Pages: [1]
Print
Author Topic: EEprom in a 18F with MikroC  (Read 6440 times)
0 Members and 1 Guest are viewing this topic.
folkeu
Active Member
***
Offline Offline

Posts: 221

Thank You
-Given: 127
-Receive: 312


« on: December 30, 2010, 05:54:40 17:54 »

Hi,
I try mikroC
I want to record and to read in eeprom of a 18F4550 a value going from 8800 to 10800 declared as " long unsigned ";
I try examples found on the web but in it reading, I see not good value in a LCD.
Would you have an example which works?
Thanks
@+
Logged
ME
Guest
« Reply #1 on: January 02, 2011, 06:48:10 18:48 »

Please post your code (even if it is not working correctly) so others can try to help you.

ME
Logged
folkeu
Active Member
***
Offline Offline

Posts: 221

Thank You
-Given: 127
-Receive: 312


« Reply #2 on: January 02, 2011, 11:34:44 23:34 »

Hi,
I have try this sample to forum of Mikroelectronica :
http://www.mikroe.com/forum/viewtopic.php?f=97&t=26484&hilit=16+bits+eeprom&start=15
Thanks
Logged
nigelmercier
Newbie
*
Offline Offline

Posts: 9

Thank You
-Given: 2
-Receive: 0


« Reply #3 on: January 03, 2011, 11:34:11 23:34 »

If you want to write to the EEPROM, you have to split the number into bytes, using Lo(), Hi(), Higher()

Code:
writeEE(ResStoreLo, Lo(resSec) ) ;  // set EEPROM lo byte 0 - 7
writeEE(ResStoreMi, Hi(resSec) ) ;  // set EEPROM mid byte 8 - 15
writeEE(ResStoreHi, Higher(resSec) ) ;  // set EEPROM hi byte 16-24

Similarly, to read it you have to reassemble from the stored bytes:

Code:
resSecL = fuelCalTab[ResStoreLo]
+ (256 * fuelCalTab[ResStoreMi])
+ (256 * 256 * fuelCalTab[ResStoreHi]) ;

Code above is from an old project, but you should get the idea.

Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC