News:

;) This forum is the property of Proton software developers

Main Menu

Best/biggest/easiest way to store data in RAM or EEPROM

Started by Amateurtje, Apr 16, 2023, 06:49 AM

Previous topic - Next topic

Amateurtje

Hi All,

I am looking for a way to store a big amount of Data (fast) . I need to store it temporarily (RAM) and later send it or I need to store it without power. I have been playing around with the SD card (module) but it is not so quick and it goes wrong a lot of times (it wreckes the file). A lot of times the file is corrupted, eventhough I close it properly etc.

So, I am thinking of storing it in RAM or ROM and sending it by wifi it save it temporarily and save it in 1 time nicely to a file on the SD card.

ROM modules I only know (and worked with) of max 512 kb. they seem to exist  also in 1 MB but more difficult to write to. But that is way to small for my purpose (datalogging).

I use (for now) the 18F46k22...

Anybody some good ideas to store stable/easy a lot of data?

trastikata

Quote from: Amateurtje on Apr 16, 2023, 06:49 AMAnybody some good ideas to store stable/easy a lot of data?

For data logging I am using FLASH memory chips - usually 16Mb or 32Mb suffice to me. Sequential writes using SPI are quite fast.

Amateurtje

Hi Trastikata,

Thanks for the anwer.
Are they also bigger available? Can you suggest me a type/name which work well?

trastikata

#3
Quote from: Amateurtje on Apr 16, 2023, 07:31 AMAre they also bigger available? Can you suggest me a type/name which work well?

Hi,

16 Mbit goes from 0.8$ to 2.5$ depending on the manufacturer. I'd say I never paid attention to the manufacturer more important is the cost per Mbit  - usually GigaDevice as they tend to be cheap and available. Of course Microchip is an option, but they are pricey.  You can find probably up to 1 or 2 Gbit in normal (not BGA) packages.

Keep in mind, those chips have around 100 000 erase cycles per sector. Also pay attention to the maximum voltage levels.

Digi-Key - FLASH Memory

Amateurtje

#4
Quote from: trastikata on Apr 16, 2023, 07:48 AMKeep in mind, those chips have around 100 000 erase cycles per sector. Also pay attention to the maximum voltage levels.

If the datalogger can be used so many times (before it breaks) it is enough... This will be used around maximum 50 times per year... :)

Quote from: trastikata on Apr 16, 2023, 07:48 AM16 Mbit goes from 0.8$ to 2.5$ depending on the manufacturer. I'd say I never paid attention to the manufacturer more important is the cost per Mbit  - usually GigaDevice as they tend to be cheap and available. Of course Microchip is an option, but they are pricey.

If going from the lower end of the price, it will be oke for the final purpose.


Do you have a piece of sample code? I was already looking a bit and the connections do not seem difficult (found a module which is called the M25P128. I could not find bigger yet but I am still looking). I never used SPI before (only I2C). is it also with SPI possible to have more than 1 module on 1 SPI port (with addresses?)

EDIT:
Looking at price, size and package, this seems a very nice one.. It is in the spec that it is 1 x 1G instead of for example 8x128... I asume this has to do with the memory adressing... Is this useable?


trastikata

#5
QuoteI was already looking a bit and the connections do not seem difficult

You need minimum four lines - MISO (Master Input Slave Output), MOSI (Master Output Slave Input), SCLK (Serial Clock) and CS/SS (Chip Select/Slave Select).

Quoteis it also with SPI possible to have more than 1 module on 1 SPI port

In SPI the CS line selects which device is currently active, so you can have as many devices as many free pins you have, if you need more than that, you can use shift registers to expand ... but I don't think you need that many  :)

QuoteLooking at price, size and package, this seems a very nice one.. It is in the spec that it is 1 x 1G instead of for example 8x128

Can't find any datasheets for this chip.

QuoteDo you have a piece of sample code?

One particularity for the FLASH chips is that you often have to Write Enable the chip prior to you can write in it. This write protection is in hardware (a Write Protection pin) which you can tie to the corresponding voltage level to disable it and in software - you need to issue a specific command before you can write.

Here's some code using software SPI from two different projects, I am quite sloppy when writing my code and comments are lacking, but the names of the Subs and the variables are self explanatory:

High WP_MEM : High HOLD_MEM : High CS_MEM : Low SCLK

Dim baFlashMemArray[256] As Byte

    FlashMemReset()
    DelayMS 25
    FlashWriteUnlock()
    DelayMS 25
    FlashMemSectorErase(0)
    DelayMS 25
    FlashMemSectorErase(3)
    DelayMS 25
    FlashMemPageWrite(0)
    DelayMS 25
    FlashMemPageWrite(64)
    DelayMS 25



Proc FlashWriteUnlock()
    FlashWriteEnable()
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x98)
    High CS_MEM
EndProc   

Proc FlashWriteEnable()
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x06)
    High CS_MEM
    DelayUS 1
EndProc
   
Proc FlashMemByteRead(dwAddress As Dword), Byte
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x03)
    SpiSendMode0(dwAddress.Byte2)
    SpiSendMode0(dwAddress.Byte1)
    SpiSendMode0(dwAddress.Byte0)
    Result = SpiReceiveMode0()
    High CS_MEM
EndProc   
   
Proc FlashMemPageWrite(dwFlashPage As Dword)
    Dim dwAddress As Dword
    Dim bA As Byte
   
    FlashWriteEnable()
   
    dwAddress =  dwFlashPage * 256
   
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x02)
    SpiSendMode0(dwAddress.Byte2)
    SpiSendMode0(dwAddress.Byte1)
    SpiSendMode0(dwAddress.Byte0)
    For bA = 0 To 255
        SpiSendMode0(baFlashMemArray[bA])
    Next
    High CS_MEM
EndProc   
   
Proc FlashMemSectorErase(wSector As Word)
    Dim dwAddress As Dword

    FlashWriteEnable()
   
    dwAddress =  wSector * 4096
   
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x20)
    SpiSendMode0(dwAddress.Byte2)
    SpiSendMode0(dwAddress.Byte1)
    SpiSendMode0(dwAddress.Byte0)
    High CS_MEM
EndProc   
 
Proc FlashMemReset()
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x66)
    High CS_MEM
    DelayUS 10
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x99)
    High CS_MEM
EndProc 

Proc SpiSendMode0(bSpiByte As Byte)
    DelayCS 1
    MOSI = bSpiByte.7 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.6 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.5 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.4 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.3 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.2 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.1 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.0 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
EndProc


Proc SpiReceiveMode0(), Byte
    DelayCS 1
    High SCLK : DelayCS 1 : Result.7 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.6 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.5 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.4 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.3 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.2 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.1 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.0 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
EndProc


Symbol SPI_Delay = 1

WRITE_BUFFER_TO_FLASH:
    GoSub WRITE_ENABLE

    GoSub START_MEM
        spi_byte = $02 : GoSub SPI_SEND_MEM   
        spi_byte = ReadWriteAddress.Byte2 : GoSub SPI_SEND_MEM 
        spi_byte = ReadWriteAddress.Byte1 : GoSub SPI_SEND_MEM
        spi_byte = ReadWriteAddress.Byte0 : GoSub SPI_SEND_MEM
       
        For b = 0 UpTo 255
            spi_byte = MemoryBuffer[b] : GoSub SPI_SEND_MEM
        Next
    GoSub STOP_MEM
Return

ERASE_FLASH_RECORD:
    For ReadWriteAddress = 0 UpTo 516096 Step 4096
        GoSub WRITE_ENABLE
       
        GoSub START_MEM
            spi_byte = $20 : GoSub SPI_SEND_MEM   
            spi_byte = ReadWriteAddress.Byte2 : GoSub SPI_SEND_MEM 
            spi_byte = ReadWriteAddress.Byte1 : GoSub SPI_SEND_MEM
            spi_byte = ReadWriteAddress.Byte0 : GoSub SPI_SEND_MEM
        GoSub STOP_MEM
       
        GoSub USB_DELAY_400MS
    Next
Return

WRITE_ENABLE:
    GoSub START_MEM
        spi_byte = $06 : GoSub SPI_SEND_MEM
    GoSub STOP_MEM
Return


START_MEM:
    Low SCLK : DelayCS SPI_Delay : Low CS_MEM : DelayCS SPI_Delay
Return

STOP_MEM:
    DelayCS SPI_Delay : High CS_MEM
Return
       

SPI_SEND_MEM:
    DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay
    MOSI = spi_byte.7 : DelayCS SPI_Delay : High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay
    MOSI = spi_byte.6 : DelayCS SPI_Delay : High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay
    MOSI = spi_byte.5 : DelayCS SPI_Delay : High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay
    MOSI = spi_byte.4 : DelayCS SPI_Delay : High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay
    MOSI = spi_byte.3 : DelayCS SPI_Delay : High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay
    MOSI = spi_byte.2 : DelayCS SPI_Delay : High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay
    MOSI = spi_byte.1 : DelayCS SPI_Delay : High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay
    MOSI = spi_byte.0 : DelayCS SPI_Delay : High SCLK : DelayCS SPI_Delay
Return

SPI_RECEIVE_MEM:
    DelayCS SPI_Delay
    High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay : spi_byte.7 = MISO : DelayCS SPI_Delay
    High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay : spi_byte.6 = MISO : DelayCS SPI_Delay
    High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay : spi_byte.5 = MISO : DelayCS SPI_Delay
    High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay : spi_byte.4 = MISO : DelayCS SPI_Delay
    High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay : spi_byte.3 = MISO : DelayCS SPI_Delay
    High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay : spi_byte.2 = MISO : DelayCS SPI_Delay
    High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay : spi_byte.1 = MISO : DelayCS SPI_Delay
    High SCLK : DelayCS SPI_Delay : Low SCLK : DelayCS SPI_Delay : spi_byte.0 = MISO : DelayCS SPI_Delay
    High SCLK : DelayCS SPI_Delay
Return 

Amateurtje

Thanks a lot, I have some interesting reading/thinking/drawing to do this week....I think this is the way to go... Save it to this and when I need to output it, I write it to a SD card. . When I can use the new pic (Q41), then I can out put this data via Wifi. (the 18F46k22 only has 2 uart ports which are already used)....

If I can find a datasheet I will post a link here. I can only find THIS but it is not exactly the same...

PS, Writing comments etc is also not my strongest point :)

trastikata

Quote from: Amateurtje on Apr 16, 2023, 09:00 AMIf I can find a datasheet I will post a link here. I can only find THIS but it is not exactly the same...

I found the datasheet: https://www.farnell.com/datasheets/3151163.pdf

The page write size is 2176 bytes and allows four partial page writes, so the buffer in the MCU should be at least 528 bytes. The blocks are 128k thus if you erase something it will have to be in 128k chunks.

I forgot to mention that erasure of FLASH chips is done in blocks, sectors or entire chip and they are usually much bigger than the page sizes - thus you can write in say for example 256 bytes "steps" but you can erase at say 8k blocks (depending on the chips).

tumbleweed

QuoteWhen I can use the new pic (Q41), then I can out put this data via Wifi. (the 18F46k22 only has 2 uart ports which are already used)
Of the currently supported 18F parts, the 18FxxQ43 has 5 uarts. The 18Fx7Q43 also has 8K of ram.


Amateurtje

#9
Quote from: tumbleweed on Apr 16, 2023, 10:49 AMOf the currently supported 18F parts, the 18FxxQ43 has 5 uarts. The 18Fx7Q43 also has 8K of ram.

I should look again but last time a did all the comparisons with the microchip tool, I ended up with very few pic who i could use...  I made a mistake (not Q41 but Q84) but I am waiting for the 18F47Q84 to be supported that I have here. Maybe I overlooked the Q43, although maybe also impossible to get your hands on nowadays? I also need significant more program space while I am running out... (not for this logger but I like to keep 1 pic for all different projects to keep my life easy.)


Quote from: tumbleweed on Apr 16, 2023, 10:49 AMThe page write size is 2176 bytes and allows four partial page writes, so the buffer in the MCU should be at least 528 bytes. The blocks are 128k thus if you erase something it will have to be in 128k chunks.

I forgot to mention that erasure of FLASH chips is done in blocks, sectors or entire chip and they are usually much bigger than the page sizes - thus you can write in say for example 256 bytes "steps" but you can erase at say 8k blocks (depending on the chips).
The logger will write "lines" of data so to handle blocks should be relatively ok.  I estimate that every line is about 250 to 300 byte data.. (I keep some reserve while I want to add more things to log in the future.)
So steps of 256 might be nice...than that is my limit for now...


 

Amateurtje

I have made a test setup and made a small program based on the script of Trastikata, Just to see something on the screen. Everything is based on the chip MT29F1G01. I used a PIC18F46k22 with a 5 to 3,3V bidirectional level converter..

https://www.farnell.com/datasheets/3151163.pdf

I do not get a reading (only zero's) ...I do not know it does not write or does not read.. Can anybody help me a bit further? Maybe some tips what to test?
The program:


Device = 18F46K22
Declare Optimiser_Level = 3
Xtal = 20
Config_Start
  FOSC = HSHP    ;HS oscillator (high power > 16 MHz)
  PLLCFG = Off    ;Oscillator used directly
  PRICLKEN = On    ;Primary clock enabled
  FCMEN = Off    ;Fail-Safe Clock Monitor disabled
  IESO = Off    ;Oscillator Switchover mode disabled
  PWRTEN = On    ;Power up timer disabled
  BOREN = On
  BORV = 190    ;VBOR set to 1.90 V nominal
  WDTEN = off;Off
  WDTPS = 2048;32768    ;1:32768
  CCP2MX = PORTC1    ;CCP2 input/output is multiplexed with RC1
  PBADEN = Off    ;PORTB<5:0> pins are configured as analog input channels on Reset
  CCP3MX = PORTB5    ;P3A/CCP3 input/output is multiplexed with RB5
  HFOFST = On    ;HFINTOSC output and ready status are not delayed by the oscillator stable status
  T3CMX = PORTC0    ;T3CKI is on RC0
  P2BMX = PORTD2    ;P2B is on RB5
  MCLRE = INTMCLR    ;RE3 input pin enabled; MCLR disabled
  STVREN = On    ;Stack full/underflow will cause Reset
  LVP = Off    ;Single-Supply ICSP disabled
  XINST = Off    ;Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
  Debug = Off    ;Disabled
  Cp0 = Off    ;Block 0 (000800-003FFFh) not code-protected
  CP1 = Off    ;Block 1 (004000-007FFFh) not code-protected     
  CP2 = Off    ;Block 2 (008000-00BFFFh) not code-protected
  CP3 = Off    ;Block 3 (00C000-00FFFFh) not code-protected
  CPB = Off    ;Boot block (000000-0007FFh) not code-protected
  CPD = Off    ;Data EEPROM not code-protected
  WRT0 = Off    ;Block 0 (000800-003FFFh) not write-protected
  WRT1 = Off    ;Block 1 (004000-007FFFh) not write-protected
  WRT2 = Off    ;Block 2 (008000-00BFFFh) not write-protected
  WRT3 = Off    ;Block 3 (00C000-00FFFFh) not write-protected
  WRTC = Off    ;Configuration registers (300000-3000FFh) not write-protected
  WRTB = Off    ;Boot Block (000000-0007FFh) not write-protected
  WRTD = Off    ;Data EEPROM not write-protected
  EBTR0 = Off    ;Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
  EBTR1 = Off    ;Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
  EBTR2 = Off    ;Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
  EBTR3 = Off    ;Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
  EBTRB = Off    ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
Config_End


All_Digital TRUE                                  ;Alle ingangen digitaal
;pullup instelingen
 WPUB = %11000000
TRISE.7 = 0
INTCON2.7=0    ; pullup geactiveerd

Declare Create_Coff On
$define pause DelayMS 200

LATA = 0
LATB = 0
LATC = 0
LATD = 0
LATE = 0

TRISA = %11110000                                ;                                       
TRISB = %11001100                                ; PORTB connected to LCD
TRISC = %10010111                                ;                                       
TRISD = %10001010
TRISE = %00001101   

Declare LCD_Lines 2                          ;TMR0
Declare LCD_DTPin  PORTA.0
Declare LCD_ENPin  PORTB.1
Declare LCD_RSPin  PORTB.0

$define CS_MEM  PORTA.5     
$define MOSI  PORTC.4       
$define SCLK  PORTC.2     
$define MISO  PORTB.2 

Symbol Hoofdstroom = PORTD.0
TRISA = %00100000                        ; poort A2 als output. A1 en A0 voor ander project
TRISB = %00000100
TRISC = %10111111

GoTo prestart

Dim i As Byte
Dim c As Word
Dim d As Byte

Symbol swAAN = 0

prestart:
    'High WP_MEM
    'High HOLD_MEM
    High CS_MEM
    Low SCLK
    pause
    Cls
    DelayMS 200
Clear
Hoofdstroom=swAAN
Cls
DelayMS 200
Start:
    For c = 0 To 535
        For d=0 To 255
            baFlashMemArray[d] = d
        Next d
        FlashMemPageWrite(c)
    Next c
    DelayMS 500
   
    Cursor 1,1
    For c = 500 To 520
        Print  Dec FlashMemByteRead (c)
    Next c

    DelayMS 5000
    Print At 1,1, "Hoi"
    DelayMS 2000
    Cls
GoTo Start



Dim baFlashMemArray[256] As Byte

    FlashMemReset()
    DelayMS 25
    FlashWriteUnlock()
    DelayMS 25
    FlashMemSectorErase(0)
    DelayMS 25
    FlashMemSectorErase(3)
    DelayMS 25
    FlashMemPageWrite(0)
    DelayMS 25
    FlashMemPageWrite(64)
    DelayMS 25



Proc FlashWriteUnlock()
    FlashWriteEnable()
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x98)
    High CS_MEM
EndProc 

Proc FlashWriteEnable()
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x06)
    High CS_MEM
    DelayUS 1
EndProc
 
Proc FlashMemByteRead(dwAddress As Dword), Byte
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x03)
    SpiSendMode0(dwAddress.Byte2)
    SpiSendMode0(dwAddress.Byte1)
    SpiSendMode0(dwAddress.Byte0)
    Result = SpiReceiveMode0()
    High CS_MEM
EndProc 
 
Proc FlashMemPageWrite(dwFlashPage As Dword)
    Dim dwAddress As Dword
    Dim bA As Byte
 
    FlashWriteEnable()
 
    dwAddress =  dwFlashPage * 256
 
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x02)
    SpiSendMode0(dwAddress.Byte2)
    SpiSendMode0(dwAddress.Byte1)
    SpiSendMode0(dwAddress.Byte0)
    For bA = 0 To 255
        SpiSendMode0(baFlashMemArray[bA])
    Next
    High CS_MEM
EndProc 
 
Proc FlashMemSectorErase(wSector As Word)
    Dim dwAddress As Dword

    FlashWriteEnable()
 
    dwAddress =  wSector * 4096
 
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x20)
    SpiSendMode0(dwAddress.Byte2)
    SpiSendMode0(dwAddress.Byte1)
    SpiSendMode0(dwAddress.Byte0)
    High CS_MEM
EndProc 
 
Proc FlashMemReset()
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x66)
    High CS_MEM
    DelayUS 10
    Low SCLK
    Low CS_MEM
    SpiSendMode0(0x99)
    High CS_MEM
EndProc

Proc SpiSendMode0(bSpiByte As Byte)
    DelayCS 1
    MOSI = bSpiByte.7 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.6 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.5 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.4 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.3 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.2 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.1 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
    MOSI = bSpiByte.0 : DelayCS 1 : High SCLK : DelayCS 1 : Low SCLK : DelayCS 1
EndProc


Proc SpiReceiveMode0(), Byte
    DelayCS 1
    High SCLK : DelayCS 1 : Result.7 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.6 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.5 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.4 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.3 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.2 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.1 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
    High SCLK : DelayCS 1 : Result.0 = MISO : DelayCS 1 : Low SCLK : DelayCS 1
EndProc


End

trastikata

Quote from: Amateurtje on Jun 25, 2023, 08:13 PMI do not get a reading (only zero's) ...I do not know it does not write or does not read.. Can anybody help me a bit further? Maybe some tips what to test?

Hi,

it's always good practice first to test if you can read from a device. Start trying to read some registers with a known value - for example the Device ID.

Once you've received the expected value you can start trying to write and read from the chip.

Read the memory datasheet carefully. What I've posted is the general case, but many FLASH chips have own specifics.

P.s. normally a FLASH chip comes with erased data thus if you read area which you have not tied to write to, you should get only 1's in all bits i.e. all bytes should be 0xFF

tumbleweed

QuoteEverything is based on the chip MT29F1G01
That chip doesn't support the same command set and won't work with the sample code shown.
It's a NAND flash... a different animal entirely.

That code is written for something like an SST26VF016B.

Amateurtje

ow.. and hat is a nand flash?

can we use that with a pic, and if so, can anybody help me with it.. I am reading the dAtasheet but it is still a bit much for me to understand completely...

Or is there another good big eeprom chip i can better use??

tumbleweed

#14
Personally I wouldn't use it.

When you say "big eeprom chip" what size are you looking for? A lot of the SPI flash devices top out at about 8MB or so, although there are larger devices out there. EEPROM devices typically much less than that.


Amateurtje

#15
I am looking to store up to about 1 Gig of data.

I am making a datalogger.

Writing to an sd card is a bit unstable and slow. (taking out the card etc can destroy the file and then all data is lost... so i am looking for more stability)

Therefore, i want to store it on-board, and when requested, save the data to the sd card.

it stores about 5 x 256 bytes = 1280 bytes per write cycle.  Probable it can be a bit less but for now I like to have some extra capacity
about 3 write cycles per second. this is the goal.

= 331.776.000 bytes per day..

Preferably I want to log a long weekend without extracting but minimum is a day of loggning.. It can be switched of during the night.

it is 324.000kb per day = = appr. 316 mb per day...

so 1 Gig is for sure some over capacity but 512mb would at least be nice... Of course, 2 or 3 mem chips on the pcb is also oke..

so writing in 1280 bytes... reading can be in bigger blocks and erasing may be everything at once.....

Ofcourse, a little bit affordable :) ;D  ;D



normnet

Neither fastest or easiest however check out IDE Hard Disk experiments.  Successfully done some time ago with a PIC18F46K80!



Amateurtje

Quote from: normnet on Jun 26, 2023, 12:30 AMNeither fastest or easiest however check out IDE Hard Disk experiments.  Successfully done some time ago with a PIC18F46K80!
Very nice project but a bit too much I think ;)  ;)  ;)

tumbleweed

#18
QuoteI am looking to store up to about 1 Gig of data
Then you'll have to modify the driver code to use the MT device.


Amateurtje

#19
Quote from: tumbleweed on Jun 26, 2023, 10:50 AM
QuoteI am looking to store up to about 1 Gig of data
You do realize the MT29F1G01 device you referenced is 1Gbit, not 1 GBbyte, right?


Yes, I realised that but it is a good beginning.  I think it even has bigger brothers  but it is a start...

If I can place in the end around 4 of these chips and have 500mb it is already a good start..

Do you think i can get this to work?  After your comment, I gave up on this chip..But I am searching like crazy to another chip but cna not find anything..

Even thinking about RAM instead of EEprom but that does not bring me further.. (and is not a really nice option)...


What I find mostly is max 32mbit... While I also reserved a lot of extra places, still, it will be a lot of data.. With 32mbit I will need way to much chips...

Micron has also NOR chips.. I really do not know the difference but is that more do-able?