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

External EEPROM (25AA1024)

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



Joined: 12 Feb 2009
Posts: 54

View user's profile Send private message

External EEPROM (25AA1024)
PostPosted: Tue Sep 29, 2009 8:25 pm     Reply with quote

Hi

I have problem to read electronic signature from the device. Currently, I'm just testing the coding using Proteus 7.2 SP6. I'm using compiler 4.084 and PIC18F252.
Hope somebody can give some idea towards this matter.
Thank you

The coding I made as below
Code:

#include <18F252.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP, NOBROWNOUT, PUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

// SPI modes
#define SPI_MODE_0  (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1  (SPI_L_TO_H)
#define SPI_MODE_2  (SPI_H_TO_L)
#define SPI_MODE_3  (SPI_H_TO_L | SPI_XMIT_L_TO_H)

void main()
{
   int8 data;

   setup_spi(SPI_MASTER | SPI_MODE_1 | SPI_CLK_DIV_16);
   
   //Deep Power-Down mode
   
   output_low(PIN_C2);     
   spi_write(0xB9);
   output_high(PIN_C2);
     
   //RELEASE FROM DEEP POWER-DOWN AND READ ELECTRONIC SIGNATURE
   output_low(PIN_C2);
   spi_write(0xAB);
   spi_write(0x00);
   spi_write(0x00);
   spi_write(0x01);
   data = spi_read(0x00); //read electronic signature
   output_high(PIN_C2);
             
   //Display data read from 25AA1024
   printf("Data = %x\r",data); //view electronic signature
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 29, 2009 8:46 pm     Reply with quote

Quote:

setup_spi(SPI_MASTER | SPI_MODE_1 | SPI_CLK_DIV_16);

Your SPI mode is wrong. Look at the left side of this timing diagram on
page 5 of the 25AA1024 data sheet:
Quote:
FIGURE 1-2: SERIAL INPUT TIMING

25AA1024 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/21836F.pdf
What SPI modes does show that it supports ? (They're shown in binary).
Choose one of the two modes and edit your setup_spi() statement.
khalis



Joined: 12 Feb 2009
Posts: 54

View user's profile Send private message

PostPosted: Tue Sep 29, 2009 8:58 pm     Reply with quote

I already change and try both modes - Mode 0,0 and 1,1 but still nothing appear in virtual terminal
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 29, 2009 9:32 pm     Reply with quote

If it doesn't work in the two modes that it says are supported, then
look for another problem in your code. Don't try to communicate in
an unsupported mode.

Start to look for problems in your code. For example, in this table
on page 4, for parameter No. 21 (Tpd), it says the time from CS going
high, until Deep Power Down mode takes effect is 100 us max:
Quote:
TABLE 1-2: AC CHARACTERISTICS (CONTINUED)

But your code puts the eeprom into Deep Power Down mode, and
then immediately tries to take it out of that mode again. I think you
should wait at least 100 us, before you try to take the chip out of
Deep Power Down mode. Try putting in a delay_us(200) statement
between the two operations.

Why did you choose a "dummy address" of 0x000001 ? I don't see
that in the data sheet. Why not use 0x000000 ?
khalis



Joined: 12 Feb 2009
Posts: 54

View user's profile Send private message

PostPosted: Tue Sep 29, 2009 10:32 pm     Reply with quote

I also tried put the delay between two operation as you suggested but still nothing displayed on the virtual terminal. The dummy address i used randomly. I thought it ok to use any numbers. It is possible the parameters of the eeprom in the proteus is not matching with the real one.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 29, 2009 10:44 pm     Reply with quote

How do you for certain that Proteus supports all commands for that
eeprom, and that they are all working correctly in your version of Proteus ?
khalis



Joined: 12 Feb 2009
Posts: 54

View user's profile Send private message

PostPosted: Wed Sep 30, 2009 12:00 am     Reply with quote

That the main problem right now..i think i need to buy and do testing on the real chip..and from that i can debug the coding... Smile
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