working with external memory


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Posts
    64


    Did you find this post helpful? Yes | No

    Default reading m25p16

    Brian:
    Thanks for your fast response...
    I am reading wav files stored in the M25P, and using this to send the address:
    cs1 = 0 'SEND COMMAND AND ADDRESS
    SHIFTOUT MOSI,SCK,1,[$03\8] 'read command $03
    SHIFTOUT MOSI,SCK,1 ,[PAGE.BYTE1\8,PAGE.BYTE0\8,00\7]'addr 000000
    I send the command and then the 24 bits address,but note in the last address byte I send
    only 7 bytes. then I go to a loop to read the data and send it to the port to convert to
    analog with a R2R network,until I find a special end of file char to stop the reading.
    If I send the 8 bits, I get shifted data. With 7 bits I got the correct data and I can identify
    the end of file byte. I do not know why.
    the read routine is this:
    ASM
    MOVLW 8
    MOVWF _CNT
    SIGUE
    BTFSS _MISO ;MOV BIT TO CHR,0
    BCF _CHR,0
    BTFSC _MISO
    BSF _CHR,0
    BSF _SCK ;READ AFTER SENDING THE CLOCK
    RLF _CHR,1
    BCF _SCK
    NOP
    NOP
    NOP
    NOP
    NOP
    DECFSZ _CNT,1
    GOTO SIGUE
    ENDASM

    Am I missing some previous command to set up the chip for reading..?

    I will test your routines to see if I got an improvement.
    Thanks again...
    Ruben de la Pena V.

  2. #2
    Join Date
    Aug 2004
    Posts
    64


    Did you find this post helpful? Yes | No

    Smile it works !...

    Brian:
    I only use the read routines for a little wav player. I use a 16F1826 at 16 mhz.(Internal Osc).
    The working routines:
    '************************************************* *****
    TESTREAD:
    CS1 = 1
    PAUSEUS 200
    CS1= 0
    code = 03 'read command
    gosub sendbyte
    code = 0 'higher add.
    gosub sendbyte
    code = 00 'high add.
    gosub sendbyte
    code = 0 'low add.
    gosub sendbyte
    nextread:
    GOSUB READBYTE
    SEROUT2 LED,32,[HEX2 REPLY," "]
    'PORTB = REPLY
    PAUSEUS 50
    GOTO nextread

    sendbyte:
    sclk = 0
    sclk = 0 : memd = code.7 : sclk = 1
    sclk = 0 : memd = code.6 : sclk = 1
    sclk = 0 : memd = code.5 : sclk = 1
    sclk = 0 : memd = code.4 : sclk = 1
    sclk = 0 : memd = code.3 : sclk = 1
    sclk = 0 : memd = code.2 : sclk = 1
    sclk = 0 : memd = code.1 : sclk = 1
    sclk = 0 : memd = code.0 : sclk = 1
    return
    Readbyte:
    sclk = 0 'data change point
    sclk = 1 : reply.7 = memq : sclk = 0
    sclk = 1 : reply.6 = memq : sclk = 0
    sclk = 1 : reply.5 = memq : sclk = 0
    sclk = 1 : reply.4 = memq : sclk = 0
    sclk = 1 : reply.3 = memq : sclk = 0
    sclk = 1 : reply.2 = memq : sclk = 0
    sclk = 1 : reply.1 = memq : sclk = 0
    sclk = 1 : reply.0 = memq : sclk = 0
    return
    '*********************************************
    I conected the M25P in port A and send the data to the PortB.
    It works up to 48 Mhz(audio), but I am using it at 16 KHZ.
    The M25P does not need anything aditional to work...
    Greetings and thanks again...
    Ruben de la Pena V.

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