PIC SRAM Integration

Discussion in 'Embedded Systems and Microcontrollers' started by peter_morley, Jan 17, 2012.

  1. peter_morley

    Thread Starter Member

    Mar 12, 2011
    179
    0
    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/p.../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)
    Code ( (Unknown Language)):
    1.     movlw   B'00000011'                     ;set WE and CE pins and make #OE Low even though it doesnt matter
    2.         movwf   PORTA                           ;PORTA holds WE and CE pins    
    3.         movff   addressL,PORTD                  ;place low bits of address into PORTD
    4.         movff   addressH,PORTE                  ;place high bits of address into PORTE
    5.         bcf     PORTA,WE                        ;make WE low
    6.         bcf     PORTA,CE                        ;after WE low make CE low also
    7.         movf    value,W                         ;wait cycle so data out doesnt affect anything
    8.         movwf   PORTC                           ;load data into address location
    I am using this format to read the SRAM
    READ CYCLE 1 (Address Controlled) (1,2)
    Code ( (Unknown Language)):
    1.     clrf    PORTC
    2.         setf    TRISC
    3.         movlw   B'00000001'                     ;setting up ram reading OE and CE is low and WE is high
    4.         movwf   PORTA  
    Here is my entire code so you can have a better scope of what I am trying to do.
    Code ( (Unknown Language)):
    1.         bsf     OSCCON,3                        ;set up external quartz crystal for 64MHz clock speed
    2.  
    3. ;clock bits    
    4.         clrf PORTA
    5.         clrf LATA
    6.         clrf TRISA
    7. ;data bits 
    8.         clrf PORTC
    9.         clrf LATC
    10.         clrf TRISC
    11. ;low address bits      
    12.         clrf PORTD
    13.         clrf LATD
    14.         clrf TRISD
    15. ;high address bits 
    16.         clrf PORTE
    17.         clrf LATE
    18.         clrf TRISE
    19.        
    20.         clrf    addressL
    21.         clrf    addressH
    22.         clrf    value
    23.  
    24. ;ram should store binary 0-255
    25. ramloop
    26.         movlw   B'00000011'                     ;set WE and CE pins and make #OE Low even though it doesnt matter
    27.         movwf   PORTA                           ;PORTA holds WE and CE pins    
    28.         movff   addressL,PORTD                  ;place low bits of address into PORTD
    29.         movff   addressH,PORTE                  ;place high bits of address into PORTE
    30.         bcf     PORTA,WE                        ;make WE low
    31.         bcf     PORTA,CE                        ;after WE low make CE low also
    32.         movf    value,W                         ;wait cycle so data out doesnt affect anything
    33.         movwf   PORTC                           ;load data into address location
    34.         incf    value                           ;increment data value
    35.         incf    addressL                        ;increment address
    36.         bz      ramdone                         ;if we previously loaded address 0xFF we need to end   
    37.         goto    ramloop                         ;and repeat
    38.  
    39. ramdone
    40.         clrf    PORTC
    41.         setf    TRISC
    42.         movlw   B'00000001'                     ;setting up ram reading OE and CE is low and WE is high
    43.         movwf   PORTA  
    44.         movlw   0xFF                       
    45.         movwf   addressL
    46.    
    47. funloop
    48.         movff   addressL,PORTD
    49.         incf    addressL
    50.         goto    funloop
     
  2. peter_morley

    Thread Starter Member

    Mar 12, 2011
    179
    0
    I figured it out.

    Seeing that no one answered, you can close this.

    It was getting very lonely in this thread.
     
Loading...