Save Parameters/Variables

If you have a simple question and just want an answer.
User avatar
xaerox
Active Member
Posts: 43
Joined: Thu Apr 30, 2015 6:12 pm

Save Parameters/Variables

Post by xaerox »

Hello everybody :)
I'm not sure, that this question is already posted here. Is it possible to save variables in flash? Let's assume, we have a simple 12-bit A/D-converter and the values will be stored in a variable. We want to save this value in flash-device, to use this value again next startup (power off-->on).

I also think, using the flash device will not be the optimal solution. Should we use the SDRAM instead?

Kind regards,
Thomas.
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Consider to use the new Microchip serial I2C EERAM (combination of SRAM and NVRAM with auto-save feature):

http://www.microchip.com/design-centers ... if-banners
colin
Experienced Member
Posts: 74
Joined: Mon Dec 16, 2013 12:14 pm

Post by colin »

Hi Xaerox,

Using xflash you can limit the boot partition size by using the option --boot-partition-size. The rest of flash memory can then be used as a data partition. Using libflash you can then write and read to that data partition. There is also the xflash option --data which will enable you to pre-load the data partition with data useful to your application if you wish.

The AppNote https://www.xmos.com/download/private/A ... rc1%29.pdf details how to use these features with QSPI however SPI is near enough the same, except for port usage and using libflash as opposed to libquadflash.

Colin.
User avatar
xaerox
Active Member
Posts: 43
Joined: Thu Apr 30, 2015 6:12 pm

Post by xaerox »

hi everybody,
thank you for your helpful answers.
I think the libflash which colin has shown is my way to save some parameters. I think the main question is answered.
Thank you!
ffomich
Experienced Member
Posts: 119
Joined: Mon Sep 15, 2014 1:32 pm

Post by ffomich »

Hi xearox,

be careful with fl_connectToDevice() - be sure you have enough time for this.

Code: Select all

timer tmr;
    unsigned start, end, connect_end, getSize_start, getSize_end, disconnect_start;
    int result = 0;

    tmr :> start;

    result = fl_connectToDevice(p_qflash, flash_devices, 1); // Connect to QSPI flash
    tmr :> connect_end;

    if (result == 0) // Connection OK
    {
        tmr :> getSize_start;
        result = ( (fl_getDataPartitionSize() > 0) ? 0 : 1); // Get DATA partition size
        tmr :> getSize_end;

        tmr :> disconnect_start;
        fl_disconnect(); // Disconnect from flash
    }
    tmr :> end;

Connect time (ticks) = connect_end - start = 247357
Read size time (ticks) = getSize_end - getSize_start = 18
Disconnect time (ticks) = end - disconnect_start = 24

1 tick @ 100 MHz = 10 ns
247357 ticks @ 100 MHz = ~2,5 ms !!!