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

Very simple ext. mem. question.

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



Joined: 07 Sep 2003
Posts: 32

View user's profile Send private message

Very simple ext. mem. question.
PostPosted: Wed Dec 17, 2003 5:16 pm     Reply with quote

Hi there,

I need to store 100Kb data in an external eeprom and display sentences with my 2*40 lcd.But unfortunately i have no idea how to connect and use external memory with 16F877.Can somebody show me a way to learn how to use memories with ccs? I really need a tutorial :( It is urgent, i need to complete my project as soon as possible :(
Thanks in advance.

Analyzer.
Guest








Re: Very simple ext. mem. question.
PostPosted: Wed Dec 17, 2003 6:27 pm     Reply with quote

Analyzer wrote:
Hi there,

I need to store 100Kb data in an external eeprom and display sentences with my 2*40 lcd.But unfortunately i have no idea how to connect and use external memory with 16F877.Can somebody show me a way to learn how to use memories with ccs? I really need a tutorial :( It is urgent, i need to complete my project as soon as possible :(
Thanks in advance.

Analyzer.


We need to know what mode of external memory either SPI or I2C?
snoopy
Guest







PostPosted: Wed Dec 17, 2003 8:09 pm     Reply with quote

Consider to use SPI memory. 25Cxxx.
connect 16f877 25Cxxx
sck 18 6 sclk
sdi 23 2 so
sdo 24 5 si
(1 pin) 1 cs

you need to configure, SPI mode

setup_spi(SPI_MASTER | SPI_H_TO_L | SPI_CLK_DIV_4);

for the moment you need to configure
spi_clk_div_x (xxx= 4, 8, 16). Depend
of the crystal frequency and and speed of your memory.
EX: CRYSTAL 20Mhz, Memory speed 8MHz 20/xxx(4)=5MHz
SPI tranfert is 5MHz.

To write in eeprom;
use fonction
Write SPI(zzz); zzz is the value to send in SPI
write_spi() is a fonction in CCS software


First
output_low(cs);
write_spi(0x06); // mode WREN for Microchip memory
output_high(cs);

output_low(cs);
write_spi(0x02); //mode write
write_spi(addh); //address high
write_spi(addl); //address low
write_spi(value);//data to put in memory
CAN STOP or write_spi(value);
output_high(cs);

CAN STOP if you write one data only put high the cs.

if you want to write some value just add value,
like you want and the address wil increment automatically.

That is the basic way to wriTe in external memory.

but the best way is to use pointer for addr an value.

Try it!
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Thu Dec 18, 2003 9:45 am     Reply with quote

If you settle on an external EEPROM you should concider the block read/write method and write your routines to access entire strings rather than bytes. If you start with this aproach you will save time in the end. Find out what the block size is for the part you chose and determine how many complete strings will fit in a block. Setup you string loading routine to use accept a string index that sequentialy addresses the strings in the external part.
Analyzer



Joined: 07 Sep 2003
Posts: 32

View user's profile Send private message

PostPosted: Thu Dec 18, 2003 5:15 pm     Reply with quote

Hi There,

Thank you for all great help.I would like to use 24xxx memories because i can not find 25xxx memories in my country :( I also can not find any model for 25xxx at Proteus 6??
By the way i will read avr. 100~150 characters per second from mem in my project.I will use 877 and 4 mhz clock.
How can i achive my goal with 24xxx?

Thanks a lot again.

Analyzer.
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Thu Dec 18, 2003 5:25 pm     Reply with quote

Analyzer wrote:
Hi There,

Thank you for all great help.I would like to use 24xxx memories because i can not find 25xxx memories in my country :( I also can not find any model for 25xxx at Proteus 6??
By the way i will read avr. 100~150 characters per second from mem in my project.I will use 877 and 4 mhz clock.
How can i achive my goal with 24xxx?

Thanks a lot again.

Analyzer.


Reading is limited by the SPI clock speed. The SPI clock can be run at 1bit per instruction. Your running 1M instruction per second. You want 150 bytes at 8 bits per byte plus about 16 bytes of addressing overhead.
Analyzer



Joined: 07 Sep 2003
Posts: 32

View user's profile Send private message

PostPosted: Thu Dec 18, 2003 6:29 pm     Reply with quote

Thank you for all your help.I referenced from ccs manual and i connected a 24LC128 to 877 and i used standart 24128.h library.It works fine but i changed pull-up resistors to 470k instead of 1k.

Analyzer.
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