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 CCS Technical Support

25LC640 on PIC18F2525

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



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

25LC640 on PIC18F2525
PostPosted: Thu Jul 02, 2015 5:40 am     Reply with quote

I want store 2345 bytes in EEPROM 25LC640.
Before I have used the 93C66 without problem. But the 93C66 was too small.

The only data that I receive from the EEPROM is 0.

Here is my code:
Code:

#include <18F2525.h>
#device ADC=10
#define FOSC 40000000 
#fuses NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP, H4
#use delay(clock=FOSC)

#define EEPROM_SELECT PIN_B4
#define EEPROM_CLK    PIN_B5
#define EEPROM_DI     PIN_C5
#define EEPROM_DO     PIN_C4


#use rs232(stream=CONTROL, baud=115200,parity=N,xmit=PIN_C3,rcv=PIN_B0,bits=8, ERRORS)

#include <25640.c>

void main(void)
{
   delay_ms(1000);
   fprintf(CONTROL, "Start\r");
     
   delay_ms(1000);
   int8 s;
   init_ext_eeprom();

   
   for(int16 i=0; i<2345; i++)
   {
      write_ext_eeprom(i,88);
   }
   
   
   for(int16 j=0; j<2345; j++)
   {
      s=read_ext_eeprom(j);
      fprintf(CONTROL, "%d",s);
   }
 
}


Compiler Version: 5.032

what's wrong?


Last edited by Prefekt on Thu Jul 02, 2015 7:25 am; edited 1 time in total
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Thu Jul 02, 2015 7:24 am     Reply with quote

Now I have found this driver here in forum.


Code:
#ifndef EEPROM_SELECT
#define EEPROM_SELECT PIN_C2
#define EEPROM_CLK    PIN_C3
#define EEPROM_DI     PIN_C5
#define EEPROM_DO     PIN_C4
#endif

#define EEPROM_ADDRESS long int
#define EEPROM_SIZE    8192

void init_ext_eeprom()
{
output_high(EEPROM_SELECT);   
setup_spi(SPI_MASTER | SPI_MODE_0_0 | SPI_CLK_DIV_16 );
}

//--------------------------------
int1 ext_eeprom_ready(void)
{
int8 data;

output_low(EEPROM_SELECT);
spi_write(0x05);
data = spi_read(0);
output_high(EEPROM_SELECT);
return(!bit_test(data, 0));
}

//--------------------------------
void write_ext_eeprom(EEPROM_ADDRESS address, BYTE data)
{
while(!ext_eeprom_ready());

output_low(EEPROM_SELECT);
spi_write(0x06);
output_high(EEPROM_SELECT);

output_low(EEPROM_SELECT);
spi_write(0x02);
spi_write(address >> 8);
spi_write(address);
spi_write(data);
output_high(EEPROM_SELECT);
}
//--------------------------------

BYTE read_ext_eeprom(EEPROM_ADDRESS address)
{
int8 data;

while(!ext_eeprom_ready());

output_low(EEPROM_SELECT);
spi_write(0x03);
spi_write(address >> 8);
spi_write(address);

data = spi_read(0);
output_high(EEPROM_SELECT);

return(data);
}



I have changed the PIN's on my board., but I get no results, only '0'
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Thu Jul 02, 2015 7:54 am     Reply with quote

You have the WP line high on the chip?.

The driver you have found does correctly set the write enable, but this will only work, if the hardware write protection is off.
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Thu Jul 02, 2015 8:40 am     Reply with quote

@Ttelmah

Thank you for your hint. Very Happy

PIN 7 was soldered on my board but the junction was not correct. With your hint, I found the error :-)

Thanks
Volker
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Thu Jul 02, 2015 11:21 am     Reply with quote

Very Happy

I looked through the posted driver, and it looked 'right', so then thought 'what else'.
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