Problem with connection to SPI SRAM 23K256


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    May 2009
    Posts
    21

    Default Problem with connection to SPI SRAM 23K256

    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

  2. #2
    Join Date
    May 2009
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    The data I read out for BI is always 255...

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    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>
    DT

  4. #4
    Join Date
    May 2009
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    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.

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I don't think the pins are 5V tolerent.
    23K256 Datasheet shows max High-level input voltage (VIH) is VCC + 0.3
    <br>
    DT

  6. #6
    Join Date
    May 2009
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    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

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Sounds like a good idea.

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

  8. #8
    Join Date
    May 2009
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    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....

  9. #9
    Join Date
    Aug 2006
    Location
    Italy
    Posts
    72


    Did you find this post helpful? Yes | No

    Default Re: Problem with connection to SPI SRAM 23K256

    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.

  10. #10
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Problem with connection to SPI SRAM 23K256

    have you a link to the datasheet for the chip ?

  11. #11
    Join Date
    Aug 2006
    Location
    Italy
    Posts
    72


    Did you find this post helpful? Yes | No

    Default Re: Problem with connection to SPI SRAM 23K256

    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.

    Datasheet Microchip SRAM 23LCV1024 - 128K_x_8.pdf

    Best regards.

Similar Threads

  1. 16-bit SPI problem
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th June 2008, 15:42
  2. SPI communication problem (newbie)
    By lm555cn in forum Serial
    Replies: 4
    Last Post: - 3rd March 2008, 15:33
  3. USART SPI problem !
    By TripleS in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th October 2007, 22:09
  4. SPI Problem?
    By NatureTech in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th January 2007, 08:43
  5. MicroCode Loader connection problem
    By muskut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th July 2005, 14:54

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts