Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 09, 2016, 02:53:37 02:53


Login with username, password and session length


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

Posts: 134

Thank You
-Given: 84
-Receive: 155


« on: December 30, 2010, 06:54:40 18: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, 07:48:10 19: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: 134

Thank You
-Given: 84
-Receive: 155


« Reply #2 on: January 03, 2011, 12:34:44 00: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 04, 2011, 12:34:11 00: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