Menu

Read and write sequentially (SPI Serial SRAM)?

17 hours ago
15 minutes ago
  • Roger Jönsson

    Roger Jönsson - 17 hours ago

    Sitting here philosophizing, wondering and looking at options...
    Can GCbasic read and write sequentially to/from a SPI Serial SRAM (like 23LC1024) ?
    -That is after sending the startadress, continuing without sending the long address for each byte.

     
  • Anobium

    Anobium - 16 hours ago

    Yes, is the answer.

    You can use the existing methods or write your own.

     
  • Roger Jönsson

    Roger Jönsson - 14 hours ago

    Existing methods I had no luck finding. I will try again tomorrow.

     
  • Anobium

    Anobium - 4 hours ago

    I would look at the Help.

    https://gcbasic.sourceforge.io/help/_sram_overview.html

    If you want to add arrays/string/pointers( to send a block of data ) then please extend the existing library. If you need help, just ask.


    I spotted a typo in the PIC example on the help web page. I am updating the online version at the moment. So, your local Windows Help will have a typo when you compile. Use the online version to get the latest web page.

     
  • Anobium

    Anobium - 4 hours ago

    I would look at the Help.

    https://gcbasic.sourceforge.io/help/_sram_overview.html

    If you want to add arrays/string/pointers( to send a block of data ) then please extend the existing library. If you need help, just ask.


    I spotted a typo in the PIC example on the help web page. I am updating the online version at the moment. So, your local Windows Help will have a typo when you compile. Use the online version to get the latest web page.

     
  • Roger Jönsson

    Roger Jönsson - 4 hours ago

    I looked there first thing and did not find anything on sending receiving sequentially without sending a long address for each byte. Then I searched this forum.
    Yes, a block of data.

     
    • Anobium

      Anobium - 3 hours ago

      OK. There is a need to extend the functionality.

      I assume the existing operations all work?

       
  • Anobium

    Anobium - 3 hours ago

    Here is an untested method to write. It would be a similar approach to read.

    I have added page addressing. Do these device need page addressing? This means do you have to write the page address when the page changes? If not remove that part of the method any just keep pushing the data out.

    Many of the variable names are shared with other methods. But, do retain these names.

    sub SRAMWriteArray ( in eepAddr as long, in eepArray(), Optional in eepLen as byte = 0 )
    
      dim eep_i as Byte                         // implies max array of 255 bytes
      dim  CalcNextPage, eepPageSize as Byte    // implies that page exist in the device
      eepPageSize = 128                         // page size
    
      dim eepromValtoSend as byte
      eepromValtoSend = eepromVal
    
      if eepLen = 0 then eepLen = eepArray(0)
    
      set SPISRAM_CS OFF
    
      SendData_SPISRAM ( SRAM_23LC_COMMAND_WRITE )
    
      #if SPISRAM_CAPACITY > 0x10000
          'Large device therefore need to send third byte address
          SendData_SPISRAM ( eepAddr_u )
      #endif
      SendData_SPISRAM ( eepAddr_h )
      SendData_SPISRAM ( eepAddr )
    
    
      for eep_i = 1 to eepLen
        SendData_SPISRAM  ( eepArray(eep_i) )   ;write next byte from array
        eepAddr++                               ;prep for next byte
        CalcNextPage = eepAddr mod eepPageSize  ; calculate next page
        if CalcNextPage = 0 then                ;end of page
          SendData_SPISRAM ( eepAddr_h )
          SendData_SPISRAM ( eepAddr )  
        end if
      next
      set SPISRAM_CS ON
    
    end sub
    

    Add to your program. When this all works move the methods into your C:\GCstudio\gcbasic\include\lowlevel\spisram.h and upload here so other can use in the future.

    I will add to the HELP etc.


    Good work!!

     
  • Roger Jönsson

    Roger Jönsson - 2 hours ago

    Thanks. I was just trying to find out the options available.
    For the idea I',m working on it is probably easier to get a processorchip with more built in RAM.
    I will save this and test later. I could definitely find use for this and if I get it to work, I will ofcourse report back.

     
  • Anobium

    Anobium - 2 hours ago

    On-board RAM will be a lot faster. A lot faster.

     
  • Roger Jönsson

    Roger Jönsson - 1 hour ago

    Combining two PIC18F27Q83 (one could be a slave, sending parallel bytes) then I would have 25kB available and cheap too. For now that is more tempting.

     
  • Anobium

    Anobium - 1 hour ago

    Maybe. Time will tell.
    Does the 27Q83 support DMA? That would even faster. Choose a DMA chip.

     
  • Roger Jönsson

    Roger Jönsson - 17 minutes ago

    Yes, It has DMA. If I will be able to handle DMA, that is for later.

     
  • Anobium

    Anobium - 15 minutes ago

    Start with DMA. It is very easy. I made video and demo to show capability. DMA will move data with CPU... it is the best method.

     
  • Anobium

    Anobium - 15 minutes ago

    Start with DMA. It is very easy. I made video and demo to show capability. DMA will move data with CPU... it is the best method.

     
  • Anobium

    Anobium - 15 minutes ago

    Start with DMA. It is very easy. I made video and demo to show capability. DMA will move data with CPU... it is the best method.

     

Log in to post a comment.