PDA

View Full Version : Problem with connection to SPI SRAM 23K256



hankshone
- 20th January 2010, 16:34
I am trying to connect the SPI SRAM 23K256 with PIC16LF877a, double checked everything about the connection and the codes,still no result...
The following is the test code I am using..I appreciate if anyone could find out what's the potential problem:
PIC16LF877A 23K256(32Kbyte RAM)


CLEAR
DEFINE OSC 4 ; System speed
DEFINE LOADER_USED 1 ;
; Define LCD registers and bits
DEFINE LCD_DREG PORTD ;
DEFINE LCD_BITS 4 ;width of data path
DEFINE LCD_DBIT 4 ;data starts on bit 4
DEFINE LCD_RSREG PORTE ;
DEFINE LCD_RSBIT 0 ;
DEFINE LCD_EREG PORTE ;
DEFINE LCD_EBIT 1 ;
INCLUDE "MODEDEFS.BAS" ;
CS VAR PORTA.5 ; Chip select pin
SCK VAR PORTC.3 ; Clock pin
SI VAR PORTC.4 ; Data in pin
SO VAR PORTC.5 ; Data out pin
ADDR VAR WORD ; Address
B0 VAR BYTE ; Data
BI VAR BYTE
bi=0
b0=0
TRISA.5 = 0 ; Set CS to output
ADCON1 = 7 ; Set PORTA and PORTE to digital
LOW PORTE.2 ; LCD R/W line low (W)
PAUSE 100 ; Wait for LCD to start up
'b0=100
FOR ADDR = 0 TO 100 ; Loop 100 times
B0 = 2 ; B0 is data for SRAM
GOSUB EEWRITE ; Write to SRAM
pause 10
NEXT ADDR
LOOP:
FOR ADDR = 0 TO 100 ; Loop 100 times
GOSUB EEREAD ; Read from SRAM
LCDOUT $FE, 1, DEC ADDR,": ",DEC Bi ; Display
PAUSE 200 ;
NEXT ADDR ;
GOTO LOOP ;
; Subroutine to read data from addr in RAM
EEREAD: CS = 0 ; Enable RAM
SHIFTOUT So, SCK, MSBFIRST, [$03, ADDR.BYTE1, ADDR.BYTE0] ; Send read cmd and address
SHIFTIN Si, SCK, MSBPRE, [BI] ; Read data
CS = 1 ; Disable
RETURN ;
; Subroutine to write data at addr in serial RAM
EEWRITE: CS = 0 ; Enable serial RAM
shIFTOUT So, SCK, MSBFIRST, [$02, ADDR.BYTE1, ADDR.BYTE0, B0] ; Send address and data
CS = 1 ; Disable
RETURN ;
END

hankshone
- 20th January 2010, 16:36
The data I read out for BI is always 255...

Darrel Taylor
- 20th January 2010, 18:08
It looks like you are using a LAB-X1 development board.

Have you modified it for 3.6V?
That SRAM isn't going to work at 5V.
<br>

hankshone
- 20th January 2010, 19:57
It looks like you are using a LAB-X1 development board.

Have you modified it for 3.6V?
That SRAM isn't going to work at 5V.
<br>

Yes, I am using the LAB-X1 board for this test.
I provided a 3.3V power supply for the SRAM. But for the SI SO SCK pins I didn't modify them to 3.3V,just connect them directly to the SRAM's pins.

Darrel Taylor
- 20th January 2010, 20:53
I don't think the pins are 5V tolerent.
23K256 Datasheet shows max High-level input voltage (VIH) is VCC + 0.3
<br>

hankshone
- 20th January 2010, 21:57
I don't think the pins are 5V tolerent.
23K256 Datasheet shows max High-level input voltage (VIH) is VCC + 0.3
<br>

Thanks Darrel I will test separately and see if I could get it through

Darrel Taylor
- 20th January 2010, 22:08
Sounds like a good idea.

Use a different chip. That one may not work anymore.
<br>

hankshone
- 22nd January 2010, 13:26
Sounds like a good idea.

Use a different chip. That one may not work anymore.
<br>

I tested on a separate circuit with a 3.0Voltage supply using PIC16LF877A and this Ram chip. There was some results come out, but not correct....
For example I wrote 100 into the first 100 location and the result come out to be 66 most of the time but some are 65. If I worte 0~100 accordingly in from address 0~100. The reads are some data from 0~66, it is also increasing accordingly, along with address shifting higher...it is weired..
I was wondering whether there is some error with my codes for these setups....

mikebar
- 20th September 2014, 04:30
Hi Hankshone,
I'm experiencing the same exact problem like yours: always reading 255
I'm using a 23LVC1025, 5 volt SRAM memory chip with 5 volt micro. But still the same problem like yours.
Did you found what the problem was?

Best regards,
Mike.

longpole001
- 27th September 2014, 02:40
have you a link to the datasheet for the chip ?

mikebar
- 27th September 2014, 02:58
Hi to everybody.
I've found the problem... my mistake. I have wired up in the opposite way the Serial In and Serial out terminal of the chip. Shame on me.
@longpole001, if you are searching for the datasheet of the 23LVC1025, then get the one attached to this message.

7456

Best regards.