CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How to create a list on a external EEPROM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Genival
Guest







How to create a list on a external EEPROM
PostPosted: Mon Dec 20, 2004 7:00 am     Reply with quote

Hello people!

I need to implement a user list on a board that use the 16F877 MCU.So, how can I create a sequence of user and how can I know the begin and the end of register of each user into the list.I'm using a 24C256 as external memory, and I need 50 user at least registred.Is it possible?If someone have some example in CCS C I'll appreciate so much for the help!
Thanks all!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 20, 2004 3:48 pm     Reply with quote

I'm sure you want something much more complicated than what I'm
going to tell you, but here goes:

A 24LC256 eeprom has 32768 bytes. If you want to partition it
into at least 50 blocks of user data, then divide 32KB by 50:
Code:

32768
------- = 655.36
 50


So you could allocate 655 bytes per user. But, it's more convenient
to use a binary number for the record size, so let's round it down to 512
bytes per user.

This program will convert a user number from 0 to 49 into a EEPROM
address. You could actually have user numbers from 0 to 63.

Code:
#include <16F877.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#define get_record_address(x)  (x << 9)

void main()
{
int8 i;
int16 record_address;

// Display the eeprom address for user numbers from 0 to 49.
for(i = 0; i < 50; i++)
   {   
    record_address = get_record_address((int16)i);
    printf("User: %u  record address: %lx \n\r", i, record_address);
   }

while(1);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group