Announcement

Collapse
No announcement yet.

Write and read word to/from flash

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Write and read word to/from flash

    Hello, i read all ducumentation from top to bottom, and also all flash related topics on that forum, but it didn't helped with so simple task as write one word and read one word back from flash memory. I tried FLASHBANKS from 1 to 5.

    To store word to flash i'm using this code:

    Code:
    var buffer[1];
    buffer[0] := 5;
    flash_WriteBlock(str_Ptr(buffer), FLASHBANK_1, 0);
    And to read word back i'm using this snippet:

    Code:
    var w;
    w := flash_GetWord(FLASHBANK_1, 0)
    But w value is allways 0(zero).

    I'm frustrated... please help.

    Display: Gen4-uLCD-43DCT-CLB-A [v2.0, 17/05/31]
    Last edited by JanValiska; 13th December 2018, 08:46 PM.

  • #2
    Hi Jan, welcome to the forum.

    Try this one. Read the comments to be guided.

    Code:
    var buff[1];        // holds 1*2 byte char
    
    func main()
    
        gfx_Set(SCREEN_MODE,LANDSCAPE) ;
    
        buff[0] := 5;
    
        if(flash_WriteBlock(buff, FLASHBANK_2, 0))
         print("Write successful!\n");
        endif
    
        pause(2000);
    
        print("Read from Flash ---> ", flash_GetWord(FLASHBANK_2,0)); // reading from flash
    
        repeat
    
        forever
    
    endfunc
    If you have any question with the implementation feel free to ask.
    Hope this will help.

    Best regards,
    Last edited by Vince_4D; 14th December 2018, 03:53 PM. Reason: Simplified the code
    Vince_4D

    Comment


    • #3
      Thank you Vince, it just works... in Slovakia exists the saying: "The morning is a wiser evening". So thank you once again

      Comment


      • #4
        No worries Jan.
        Have fun exploring our product!

        Kindest regards,
        Vince_4D

        Comment

        Working...
        X