Need Help ON the SPI F-RAM....


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

    Default Need Help ON the SPI F-RAM....

    I am trying to inteface SPI-FRAM with PIC16F877A for a long time. I am sure the hardware connection is correct. Just got some wired results....See anybody can tell me what's the reason and is there any solution...
    I really appreciate any suggestions you might have....

    FRAM-FM25V10 datasheet:
    [HTML]http://www.ramtron.com/files/pdfs/FM25V10ds_r1-0.pdf[/HTML]

    What I am trying to do is write the first 255 locations with 1~255 respectively. the Code and the result is followed:
    Code:
    '****************************************************************
    '*  Name    : SPI_FRAM_TEST.BAS                                 *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 2/10/2010                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    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"	; 
    
    '--------------------------Serial Port setting up-------------------------------  
     DEFINE HSER_RXSTA 90H
     DEFINE HSER_TXSTA 20H
     DEFINE HSER_BAUD 2400
     DEFINE HSER_SPBRG 25      
    '-------------------------------------------------------------------------------
    
    
    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
    BLOCK1  VAR    BYTE
    BLOCK0  VAR    BYTE 
    B0       VAR   WORD 		; Data
    B0=0
    
    BLOCK0=%00000000;
    BLOCK1=%00000001
    
    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
    FOR ADDR = 1 TO 1000		; Loop 16 times
    	B0 =b0+1; 		 ; B0 is data for SEEPROM
    	GOSUB EEWRITE 	; Write to SEEPROM
    	'PAUSE 10		; Delay 10ms after each write
    NEXT ADDR
    
    LOOP:   FOR ADDR = 0 TO 1000	; Loop 16 times
    	GOSUB EEREAD		; Read from SEEPROM
    	hserout [dec4 addr];
    	hserout [" "];
    	hserout [bin8 b0,13]
    	LCDOUT $FE, 1, #ADDR,": ",#B0	 ; Display
    	PAUSE 100		; 
    	NEXT ADDR		; 
    GOTO LOOP			; 
    				; Subroutine to read data from addr in serial EEPROM
    EEREAD: CS = 0 			; Enable serial EEPROM
    	SHIFTOUT SO, SCK, , [$03, BLOCK1,ADDR.byte1,addr.byte0]  ; Send read cmd and address
    	SHIFTIN SI, SCK, MSBPRE, [B0]   ; Read data
    	CS = 1			; Disable
    RETURN				; 
    				; Subroutine to write data at addr in serial EEPROM
    EEWRITE: CS = 0	; Enable serial EEPROM
    	SHIFTOUT SO, SCK, 5, [$06]       ; Send write enable command
    	CS = 1			 ; Disable to execute command
    	CS = 0			 ; enable
    	SHIFTOUT SO, SCK, MSBFIRST, [$02,BLOCK1,addr.byte1, ADDR.byte0,B0]   ; Send address and data
    	CS = 1			; Disable
    RETURN				; 
    END				; always end all programs with an END statement


    ANd the result:
    [HTML]0000 00000011
    0001 00000001
    0002 00000011
    0003 00000011
    0004 00000111
    0005 00000111
    0006 00000111
    0007 00000111
    0008 00001111
    0009 00001111
    0010 00001111
    0011 00001111
    0012 00001111
    0013 00001111
    0014 00001111
    0015 00001111
    0016 00011111
    0017 00011111
    0018 00011111
    0019 00011111
    0020 00011111
    0021 00011111
    0022 00011111
    0023 00011111
    0024 00011111
    0025 00011111
    0026 00011111
    0027 00011111
    0028 00011111
    0029 00011111
    0030 00011111
    0031 00011111
    0032 00111111
    0033 00111111
    0034 00111111
    0035 00111111
    0036 00111111
    0037 00111111
    0038 00111111
    0039 00111111
    0040 00111111
    0041 00111111
    0042 00111111
    0043 00111111
    0044 00111111
    0045 00111111
    0046 00111111
    0047 00111111
    0048 00111111
    0049 00111111
    0050 00111111
    0051 00111111
    0052 00111111
    0053 00111111
    0054 00111111
    0055 00111111
    0056 00111111
    0057 00111111
    0058 00111111
    0059 00111111
    0060 00111111
    0061 00111111
    0062 00111111
    0063 00111111
    0064 01111111
    0065 01111111
    0066 01111111
    0067 01111111
    0068 01111111
    0069 01111111
    0070 01111111
    0071 01111111
    0072 01111111
    0073 01111111
    0074 01111111
    0075 01111111
    0076 01111111
    0077 01111111
    0078 01111111
    0079 01111111
    0080 01111111
    0081 01111111
    0082 01111111
    0083 01111111
    0084 01111111
    0085 01111111
    0086 01111111
    0087 01111111
    0088 01111111
    0089 01111111
    0090 01111111
    0091 01111111
    0092 01111111
    0093 01111111
    0094 01111111
    0095 01111111
    0096 01111111
    0097 01111111
    0098 01111111
    0099 01111111
    0100 01111111
    0101 01111111
    0102 01111111
    0103 01111111
    0104 01111111
    0105 01111111
    0106 01111111
    0107 01111111
    0108 01111111
    0109 01111111
    0110 01111111
    0111 01111111
    0112 01111111
    0113 01111111
    0114 01111111
    0115 01111111
    0116 01111111
    0117 01111111
    0118 01111111
    0119 01111111
    0120 01111111
    0121 01111111
    0122 01111111
    0123 01111111
    0124 01111111
    0125 01111111
    0126 01111111
    0127 01111111
    0128 10000000
    0129 10000001
    0130 10000011
    0131 10000011
    0132 10000111
    0133 10000111
    0134 10000111
    0135 10000111
    0136 10001111
    0137 10001111
    0138 10001111
    0139 10001111
    0140 10001111
    0141 10001111
    0142 10001111
    0143 10001111
    0144 10011111
    0145 10011111
    0146 10011111
    0147 10011111
    0148 10011111
    0149 10011111
    0150 10011111
    0151 10011111
    0152 10011111
    0153 10011111
    0154 10011111
    0155 10011111
    0156 10011111
    0157 10011111
    0158 10011111
    0159 10011111
    0160 10111111
    0161 10111111
    0162 10111111
    0163 10111111
    0164 10111111
    0165 10111111
    0166 10111111
    0167 10111111
    0168 10111111
    0169 10111111
    0170 10111111
    0171 10111111
    0172 10111111
    0173 10111111
    0174 10111111
    0175 10111111
    0176 10111111
    0177 10111111
    0178 10111111
    0179 10111111
    0180 10111111
    0181 10111111
    0182 10111111
    0183 10111111
    0184 10111111
    0185 10111111
    0186 10111111
    0187 10111111
    0188 10111111
    0189 10111111
    0190 10111111
    0191 10111111
    0192 11000000
    0193 11000001
    0194 11000011
    0195 11000011
    0196 11000111
    0197 11000111
    0198 11000111
    0199 11000111
    0200 11001111
    0201 11001111
    0202 11001111
    0203 11001111
    0204 11001111
    0205 11001111
    0206 11001111
    0207 11001111
    0208 11011111
    0209 11011111
    0210 11011111
    0211 11011111
    0212 11011111
    0213 11011111
    0214 11011111
    0215 11011111
    0216 11011111
    0217 11011111
    0218 11011111
    0219 11011111
    0220 11011111
    0221 11011111
    0222 11011111
    0223 11011111
    0224 11100000
    0225 11100001
    0226 11100011
    0227 11100011
    0228 11100111
    0229 11100111
    0230 11100111
    0231 11100111
    0232 11101111
    0233 11101111
    0234 11101111
    0235 11101111
    0236 11101111
    0237 11101111
    0238 11101111
    0239 11101111
    0240 11110000
    0241 11110001
    0242 11110011
    0243 11110011
    0244 11110111
    0245 11110111
    0246 11110111
    0247 11110111
    0248 11111000
    0249 11111001
    0250 11111011
    0251 11111011
    0252 11111100
    0253 11111101
    0254 11111110
    0255 11111111
    [/HTML]

  2. #2
    Join Date
    Jan 2010
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    I havent used the SHIFTOUT/SHIFTIN commands but do you need to specify the MODE in your EEREAD routine?

    SHIFTOUT SO, SCK, , [$03, BLOCK1,ADDR.byte1,addr.byte0]

    It is specified as MSBFIRST in your EEWRITE routine.

    SHIFTOUT SO, SCK, MSBFIRST, [$02,BLOCK1,addr.byte1, ADDR.byte0,B0]

Similar Threads

  1. Using SPI with External Interrupts
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th June 2008, 04:08
  2. 16-bit SPI problem
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th June 2008, 15:42
  3. Replies: 4
    Last Post: - 3rd January 2008, 23:41
  4. SPI Interfacing
    By toofastdave in forum Serial
    Replies: 8
    Last Post: - 18th November 2007, 11:15
  5. How to configure SPI in PICBASIC PRO?
    By moogle in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th April 2007, 18:31

Members who have read this thread : 0

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