View previous topic :: View next topic |
Author |
Message |
Analyzer
Joined: 07 Sep 2003 Posts: 32
|
Very simple ext. mem. question. |
Posted: Wed Dec 17, 2003 5:16 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
Re: Very simple ext. mem. question. |
Posted: Wed Dec 17, 2003 6:27 pm |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
snoopy Guest
|
|
Posted: Wed Dec 17, 2003 8:09 pm |
|
|
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! |
|
![](templates/subSilver/images/spacer.gif) |
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Thu Dec 18, 2003 9:45 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Analyzer
Joined: 07 Sep 2003 Posts: 32
|
|
Posted: Thu Dec 18, 2003 5:15 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Thu Dec 18, 2003 5:25 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Analyzer
Joined: 07 Sep 2003 Posts: 32
|
|
Posted: Thu Dec 18, 2003 6:29 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|