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

Amtel 25256 EEPROM problem

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



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

Amtel 25256 EEPROM problem
PostPosted: Sun Aug 10, 2008 4:21 pm     Reply with quote

Hey guys,

I replaced my existing EEPROM with another EEPROM (amtel 25256) and changed the connections based on a working board, now it does not seem to work. The microcontroller is still 16F877A

The connections are as follows

PIN1-CS to PIN C1

PIN2- SO to PIN C5 - pulled up by 10k

PIN3- WP to Vcc

PIN4-GND

PIN5- SI to PIN C4

PIN6- SCK to PIN C3

PIN7-HOLD to Vcc

PIN8-Vcc

Vcc is 3.3v


The code used to test this eeprom is as follows:
Code:


#include <16F877A.h>
//#include <25640.h>

#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#include <stdio.h>
#include "lcd2.c"

#define TRUE 1

#include "EEPROM.c"


void main()
{
 
 BYTE d,c;
 int b;
 lcd_init();
 init_ext_eeprom();//initializing EEPROM
 while(1)
{
b = ext_eeprom_ready();
while(b==1)
{

write_ext_eeprom(0,0x01); //0 = start address, c= data

d = read_ext_eeprom(0);//  Read the byte d from the address a
lcd_putc(d);
delay_ms(1000);
}
}}



the EEPROM header file is as follows

Code:



#define EEPROM_SELECT PIN_C1 //changed
#define EEPROM_CLK    PIN_C3 //changed
#define EEPROM_DI     PIN_C4 //changed
#define EEPROM_DO     PIN_C5 //changed


#ifndef EEPROM_ADDRESS
#define EEPROM_ADDRESS long
#endif

#byte SSPSTAT=0x94
#byte SSPCON=0x14

//Rest of it is the same as that in the header file.



Any suggestions?

Regards

Terry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 10, 2008 4:51 pm     Reply with quote

1. Why is the 25640.c driver file commented out ?

2. What is the Vdd voltage on the PIC ? If it's 3.3v, are you using
the "LF" version of the PIC ?

3. Why are SSPSTAT and SSPCON declared ? The CCS 25640.c
driver is a software SPI driver. It doesn't use hardware SPI.
tranz



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Sun Aug 10, 2008 4:57 pm     Reply with quote

Since I am using a different EEPROM I commented out the 25640.c file, the file I am using for the EEPROM is EEPROM.c

Which is the same as "AT25256.c" since I am using that EEPROM.
tranz



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Sun Aug 10, 2008 4:59 pm     Reply with quote

CORRECTION on Vcc its 5 V.

Sorry about that.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 10, 2008 5:13 pm     Reply with quote

OK, now I understand.

Quote:
while(1)
{
b = ext_eeprom_ready();
while(b==1)
{

The write_ext_eeprom() routine in AT25256.c calls ext_eeprom_ready(),
so you shouldn't have to call it in your code.


Quote:
lcd_putc(d);

Because you are writing 0x01 to the eeprom, assuming that you read it
back OK, you won't see "01" displayed on the LCD. It will be some
control character. If you want to see the actual hex value, then you
need to format it with printf and re-direct the output of printf to the LCD.
Example:
Code:
printf(lcd_putc, "\fValue= %2X", d);
tranz



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Sun Aug 10, 2008 5:21 pm     Reply with quote

I did the modifications on the code as suggested, but the compiler is not running past "write_ext_eeprom(0,0x01);"

As I debugged it further, it seems not to fulfill the condition "ext_eeprom_ready(); "

Suggestions?
tranz



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Mon Aug 11, 2008 8:33 am     Reply with quote

New results,

When the individual pins of the EEPROM are looked into via scope, the SCK is working, but SI and SO are high, no data is being sent or recieved on those lines.

Any Suggestions?
Ttelmah
Guest







PostPosted: Mon Aug 11, 2008 10:11 am     Reply with quote

If you look at write_ext_eprom, you will see that it won't start the actual write, till the chip is 'ready'. If you look at the code for this, it drops the EEPROM_SELECT line, and then outputs the data bit for a status command, on EEPROM_DI, and clocks EEPROM_CLK. If these lines are not operating, something is wired wrong, or setup wrong in the configuration...
Disconnect everything from the PIC. You should see EEPROM_DI changing.
Other things. Though you talk about EEPROM.h, you don't show where this is included. Why have you renamed the standard driver?.
Code:

#include <16F877A.h>
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#include <stdio.h>
#include "lcd2.c"

#define TRUE 1
#define EEPROM_SELECT PIN_C1 //changed
#define EEPROM_CLK    PIN_C3 //changed
#define EEPROM_DI     PIN_C4 //changed
#define EEPROM_DO     PIN_C5 //changed

#include "AT25256.c"
//The driver _automatically_ accepts pin definitions made before it.

void main() {
 
 BYTE d,c;
 int b;
 lcd_init();
 init_ext_eeprom();//initializing EEPROM
 while(1) {
    write_ext_eeprom(0,0x01); //0 = start address, c= data
    d = read_ext_eeprom(0);//  Read the byte d from the address a
    lcd_putc(d);
    delay_ms(1000);
 }
}

The standard driver is written, so you just define the pins you want, and load it. It automatically uses your definitions.

Best Wishes
tranz



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Mon Aug 11, 2008 12:39 pm     Reply with quote

Thanks Ttelmah,

Yeah I used the original driver, and swapped the data lines and it worked.

Thanks again for the help.

Cheers
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 11, 2008 12:41 pm     Reply with quote

Not to beat up on you, but that's the exact same problem you had in
your earlier eeprom thread. I would check the data lines first from now on.
http://www.ccsinfo.com/forum/viewtopic.php?t=35479&start=15
tranz



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Tue Aug 12, 2008 7:59 am     Reply with quote

Yeah, I know this time I got a bit confused with the MISO and MOSI thing wires.

Thanks again, sorry for the inconvenience caused.

Cheers
tranz



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Fri Aug 15, 2008 10:20 am     Reply with quote

Well I am facing a new problem with my amtel EEPROM, as the data gets stored I am incrementing the address, by 1.

The funny part is although the datasheet says I have 32,768 words/bytes to play with, the address counter stops at 255.

Code:

void main()
      {
      byte c,x;
      int b=0;
                 
      lcd_init();
 
   
      init_ext_eeprom();//initializing EEPROM
     
      c=fgetc(HOSTPC);

      write_ext_eeprom(b, c);

      printf(lcd_putc,"value=%2X ",c);

      b=b+1;
     
      do {

      x=fgetc(HOSTPC);
      write_ext_eeprom(b, x);
      printf(lcd_putc,"\fvalue=%2X ",x);
      b=b+1;
      while(b==5120)
      {
       output_high(PIN_C2);
       delay_ms(5000);
       output_low(PIN_C2);
      }
      }while (1);
      }



So based on this code, b should be incremented till 5120, and then it should blink an LED.

But the entire system just stops at b=255.

What am I doing wrong?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 15, 2008 10:34 am     Reply with quote

Download the CCS manual.
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Look at the table called "Basic and Special Types" on page 37.
(page 49 in the Acrobat reader).

Look at the size of the data types. Look at the small table just
below the big one, which shows how "C Standard Types" compare
to CCS data types.
tranz



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Fri Aug 15, 2008 11:05 am     Reply with quote

Yeah works with int16.

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