PIC SRAM Integration

Thread Starter

peter_morley

Joined Mar 12, 2011
179
I am trying to use an external SRAM in which the PIC will send 16 bit data addresses to write and read to the SRAM.
I use PORTC as data in and data out for the SRAM.
I use PORTD and PORTE and my address bits for the SRAM.
My big concern here is am I doing the correct read and write operations.

My SRAM is here... http://download.siliconexpert.com/pdfs/2008/08/12/c/manual/alcm/sram/as6c4008 feb 2007 with tsop 11.pdf

I am using this format to write to the SRAM
WRITE CYCLE 2 (CE# Controlled) (1,2,5,6)
Rich (BB code):
	movlw	B'00000011'						;set WE and CE pins and make #OE Low even though it doesnt matter
		movwf	PORTA							;PORTA holds WE and CE pins		
		movff	addressL,PORTD					;place low bits of address into PORTD
		movff	addressH,PORTE					;place high bits of address into PORTE
		bcf		PORTA,WE						;make WE low
		bcf		PORTA,CE						;after WE low make CE low also
		movf	value,W							;wait cycle so data out doesnt affect anything
		movwf	PORTC							;load data into address location
I am using this format to read the SRAM
READ CYCLE 1 (Address Controlled) (1,2)
Rich (BB code):
	clrf	PORTC
		setf	TRISC
		movlw	B'00000001'						;setting up ram reading OE and CE is low and WE is high
		movwf	PORTA
Here is my entire code so you can have a better scope of what I am trying to do.
Rich (BB code):
		bsf		OSCCON,3						;set up external quartz crystal for 64MHz clock speed

;clock bits		
		clrf PORTA 
		clrf LATA 
		clrf TRISA
;data bits	
		clrf PORTC 
		clrf LATC 
		clrf TRISC 
;low address bits		
		clrf PORTD 
		clrf LATD 
		clrf TRISD 
;high address bits	
		clrf PORTE 
		clrf LATE
		clrf TRISE 
		
		clrf	addressL
		clrf	addressH
		clrf	value

;ram should store binary 0-255
ramloop
		movlw	B'00000011'						;set WE and CE pins and make #OE Low even though it doesnt matter
		movwf	PORTA							;PORTA holds WE and CE pins		
		movff	addressL,PORTD					;place low bits of address into PORTD
		movff	addressH,PORTE					;place high bits of address into PORTE
		bcf		PORTA,WE						;make WE low
		bcf		PORTA,CE						;after WE low make CE low also
		movf	value,W							;wait cycle so data out doesnt affect anything
		movwf	PORTC							;load data into address location
		incf	value							;increment data value
		incf	addressL						;increment address
		bz		ramdone							;if we previously loaded address 0xFF we need to end	
		goto	ramloop							;and repeat

ramdone
		clrf	PORTC
		setf	TRISC
		movlw	B'00000001'						;setting up ram reading OE and CE is low and WE is high
		movwf	PORTA	
		movlw	0xFF						
		movwf	addressL
	
funloop
		movff	addressL,PORTD
		incf	addressL
		goto	funloop
 
Top