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

EEPROM connected via SPI
Goto page 1, 2  Next
 
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

EEPROM connected via SPI
PostPosted: Mon Jul 21, 2008 9:11 am     Reply with quote

Hello,

I have connected 25LC640 to my pic 16F877A via SPI. But since the driver file of 25LC640 uses just the normal I/O pins, I used the same. Although connected to SPI based pins, i have used the same pins as I/O for the EEPROM.

And it does not work! So the question is, is it necessary to use SPI functionality when connecting the SPI pins, or can they be used as general I/o pis as well. According to me that should not be a problem, but then it does not seem to work.

Any suggestions will be helpful.

Thanks

Tranz
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 21, 2008 11:51 am     Reply with quote

1. Post the list of connections to the eeprom. Post the pin number on
the PIC and the pin number that it connects to on the eeprom.
Also post the connections to the \WP and \HOLD pins on the eeprom.

2. Post a small test program that calls the CCS driver functions. Make
sure the posted program is complete and compilable (but very small).

3. Post your compiler version.
tranz



Joined: 10 Feb 2007
Posts: 78

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

PostPosted: Mon Jul 21, 2008 12:24 pm     Reply with quote

Pins which are connected

Code:

#define EEPROM_SELECT PIN_A4
#define EEPROM_CLK      PIN_C3
#define EEPROM_DI        PIN_C5
#define EEPROM_DO       PIN_C4

PIN 3 (Write Protect), 7 (HOLD), 8(Vcc) connected to 3.3V
PIN 4 connected to GND
 


Test Program

Code:


#include <16F877A.h>
#include <25640.h>
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, STREAM=HOSTPC)
//#use spi (FORCE_HW, BITS=16, stream=SPI_STREAM)

#include <stdio.h>
#include "lcd2.c"

#define TRUE 1

void main()
{
 
 BYTE d,c;
 int b;

 init_ext_eeprom();//initializing EEPROM
 b = ext_eeprom_ready();
 while(b==1)
 {
 write_ext_eeprom(0, 0x09); //0 = start address, c= data
 d = read_ext_eeprom(0);//  Read the byte d from the address a
 lcd_putc(d);
 }
}



The compiler version I am using is PCWH, CCS C compiler
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 21, 2008 12:52 pm     Reply with quote

That's not the version. The version is a number in this format: x.xxx
It's given at the top of the .LST file, which is in your project directory.


But first, do you have a pull-up resistor (4.7K) on pin A4 ?
That's an open-drain pin. It can't drive to a high level by itself.
Ideally, you should change it to use a different pin.
tranz



Joined: 10 Feb 2007
Posts: 78

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

PostPosted: Mon Jul 21, 2008 1:21 pm     Reply with quote

NO I dont have a pull up resistor on PIN A4.. so I would have to place a 4.7k on it..and the other end has to be connected to 3.3v ?

I would not be able to change the PIN_A4 to something else since I am already short of pins for the project that I am involved in.

The version number is 4.736
tranz



Joined: 10 Feb 2007
Posts: 78

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

PostPosted: Mon Jul 21, 2008 1:23 pm     Reply with quote

Sorry the version Number is 4.023. My bad.

Thanks,

Tranz
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 21, 2008 2:12 pm     Reply with quote

I have a question. Is this running on a real board or is this Proteus ?
The 16F877A data sheet says that for the regular version of the chip,
the minimum Vdd voltage is 4.0 volts. The "LF" version can run at
+3.3v, but it's limited to 10 MHz crystal frequency, max.
So your configuration doesn't make any sense unless it's not real.
I.e, it's being run as a Proteus simulation.

Regarding the pull-up, if the board is running at +3.3v (PIC and eeprom),
then you can use a 3.3K pullup on pin A4. Connect it to +3.3v.
tranz



Joined: 10 Feb 2007
Posts: 78

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

PostPosted: Mon Jul 21, 2008 4:03 pm     Reply with quote

No its not Proteus.

I have developed a 3 boards actually and trying to interface them. The EEPROM is on a different board which is running at 3.3V. The PIC is on another board which is running on 5V , so the signals coming from the pic are stepped down to 3.3V via a voltage regulator.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 21, 2008 4:32 pm     Reply with quote

Quote:
so the signals coming from the pic are stepped down to 3.3V via a voltage regulator.

A voltage regulator doesn't step down signals. You would need a level
shifter to do that (either an integrated circuit or possibly a voltage divider
made from two resistors).
Ttelmah
Guest







PostPosted: Mon Jul 21, 2008 4:35 pm     Reply with quote

Voltage regulator!....
I hope not...
The supply can be stepped down with this, but the signals need more. For the signals coming from the 5v chip the 3.3v device, a resistor potential divider _mat_ be adequate. You need reasonably low resistor values if you are going to maintain good edges on the signal lines. For the signal coming the other way, you need to look carefully at the input requirements of the PIC pin, and the output drive of the EEPROM. Normally PortC pins have ST input buffers. As such you _will_ a 3.3v to 5v interface driver on this line (haven't got the 877A data sheet handy to see what it has).
Without resistive dividers, the PIC will be trying to raise the 3.3v supply rail to 5v. Without a level shifter, the PIC probably will never see a logic 'high' on the input line.

Best Wishes
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jul 21, 2008 5:04 pm     Reply with quote

tranz wrote:
Sorry the version Number is 4.023.
And not mentioned by the others, but the early v4.xxx compiler versions were highly unstable. The compiler became more or less usable again at v4.030. For more info see the sticky thread on the V4 compiler in this forum.
tranz



Joined: 10 Feb 2007
Posts: 78

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

PostPosted: Thu Jul 24, 2008 10:49 am     Reply with quote

Thank you for all your responses, I have made the necessary harware changes. Now the current configuration is something like this between the 3.3v EEPROM and 5 V microcontroller.

CS pin between the PIC and the EEPROM is connected via 1k resistor and pulled down via 10K resistor

SI connection between EEPROM and PIC is connected via a Diode, so instead of a solid 0V on the SI pin, the 3.3V device would have 0.6V applied to SI pin. 0.6V is low enough to be considered a digital '0' in this case. This line is also pulled up to 3.3v via 10K res.

SCK pins are connected via 10K res.

After all these hardware changes, it still does not work with the 25640.h file. I was wondering if the SPI version of this file would make it work or not.

Any suggestions?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 24, 2008 11:14 am     Reply with quote

Quote:
CS pin between the PIC and the EEPROM is connected via 1k resistor and pulled down via 10K resistor

But you have \CS on pin A4 of the PIC. That's an open-drain pin.
It requires a pull-up resistor on it. You should have put a 3.3K pull-up
on it, and connected the pull-up to +3.3v. Then you would have the
correct voltage levels going from the PIC to the eeprom (for that pin).


Quote:
SCK pins are connected via 10K res.

That should have been a voltage divider, with the values calculated
to reduce the 5v cmos levels coming from the PIC, down to the 3.3v
cmos levels required by the eeprom.

I think you should get rid of the +3.3v board and get a 25LC640 and
put it on the PIC board, and see if you can get it working there first.
Once you have that done, then try interfacing to a +3.3v board.
tranz



Joined: 10 Feb 2007
Posts: 78

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

PostPosted: Thu Jul 24, 2008 11:27 am     Reply with quote

The A4 pin was not working so I connected C1 pin to it.

Yes I will try that but before I did I wanted to check the SPI version of it and see if that works or not. But in any case will give it a try.

Thanks
tranz



Joined: 10 Feb 2007
Posts: 78

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

PostPosted: Tue Jul 29, 2008 3:23 pm     Reply with quote

I have connected the ext EEPROM on the 5 V board, and the pins connected to the EEPROM are sending the signal ( measured via oscilloscope), but still when I run the test code, it does not work, any ideas ??

Thanks for all the responses.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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