Author Topic: Extending the parameter block with my own variables  (Read 8422 times)

Offline FAQ

  • Newbie
  • *
  • Posts: 27
    • View Profile
Extending the parameter block with my own variables
« on: April 06, 2009, 09:51:54 PM »
I am a little confused on the uParameter system. Can I put in
variables into the PARS struct and will automatically save and get
recalled?

How would I save and then recall after reload?

Thanks

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Extending the parameter block with my own variables
« Reply #1 on: April 06, 2009, 09:53:08 PM »
Hi

1) You can extend PARS with your own (additional) parameters.

2) Be sure to increment the value of ucParVersion each time you modify the structure. This will cause it to no longer recognized (old) parameters saved in FLASH as being valid and take the defaults again (it avoids the SW trying to work with parameters which are no longer valid).

3) You can save all parameters, including your own extended parameters, by using fnSaveNewPars() as described in http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF (or lower level calls)

4) When the board resets it will automatically read the parameters and copy them to the "parameters" block (which is a copy in RAM).

Regards

Mark

Offline saurabh

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Extending the parameter block with my own variables
« Reply #2 on: September 30, 2009, 02:45:32 PM »
Hey Mark,

I am using LPC2388 controller, with 512 KB flash.

I have extended structure PARS block with my application parameters , and size of total PARS   now goes to 2016 bytes,
and size of TEMPPARS(which also contains object of PARS goes to  2040 bytes.

I am making use of existing functions
Code: [Select]
fnSaveNewPars,

It works parameters blocks size upto some 2046 bytes,

If I am adding more parameters after this, it is not working and I m getting garbage values for newly added parameters.

To accommodate more parameters (my req. is 5 KB of NV Variables to store at flash)
I have made following changes in various Macros values

I changed

#define uFILE_START  (FLASH_START_ADDRESS + FLASH_SECTOR_15_OFFSET)  
                               (old was 17th sector, my code will take at most upto 13th sector)


#define FILE_SYSTEM_SIZE (3*FLASH_GRANULARITY_LARGE)
                               (old was 5*FLASH_GRANULARITY_LARGE) + (4*FLASH_GRANULARITY_SMALL)


#define PARAMETER_BLOCK_GRANULARITY     (FLASH_GRANULARITY_LARGE)
                                (old was FLASH_GRANULARITY_SMALL)
                

#define PARAMETER_BLOCK_START   FLASH_SECTOR_18_OFFSET
                                (old was FLASH_SECTOR_26_OFFSET)

#define PAR_BLOCK_SIZE  (4*PARAMETER_BLOCK_SIZE)

i keep set
   #define USE_PARAMETER_BLOCK                                
    #define USE_PAR_SWAP_BLOCK




I tried to understand why 32 KB of flash sector only allow to store parameters values upto 2040 bytes?! .

I could find in the flash file system document that

"If a device doesn’t support “accumulative writes” it is necessary to use one FLASH
word (size of word depends on device) per variable byte. An example of this is the
M9S12NE64, which uses 16 bit FLASH words and cannot perform accumulative
writes. When a block of user parameters is saved, each of the bytes in the block of
variables is saved in an individual word. A parameter block of 512 bytes (the FLASH
granularity in the NE64) can therefore save (512 – 4)/2 bytes [254] of user data."

I could understand (if so!) that with LPC2388 it can save ((32*1024) - 2(16))/16 , 2046 Bytes
of data due to flash word length is 16. isn't it?


But sill I increase PAR_BLOCK_SIZE  to (4*PARAMETER_BLOCK_SIZE) then it should work
for (2046*2)=4092 Bytes.... :-[  but it is still stores only 2046 bytes


Will you pls tell me how can I accomplish storage of bigger data (parameters upto 5K) with uParameter System.

-
Thanks
Saurabh
« Last Edit: September 30, 2009, 03:36:31 PM by saurabh »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Extending the parameter block with my own variables
« Reply #3 on: September 30, 2009, 04:49:43 PM »
Hi Saurabh

The LPC2XXX have a FLASH line length of 16, as you calculated (see also here where it is explained: http://www.utasker.com/forum/index.php?topic=136.0).

This make the parameter system very inefficient since it it designed to allow writing of single bytes without disturbing others, which is only possible by allocating a complete line of 16 bytes for each byte of parameter.

Normally the parameter block size is made the same as the FLASH granularity and I don't remember ever using a parameter block consisting of multiple FLASH sectors, but I also don't known of a restriction to doing so. I will have to test this configuration to verify whether this is the case or not and will report back when I know the answer to it.

However I am also wondering whether the parameter system is the best method for storing your large amount of data (based on the fact that the LPC2XXX FLASH makes this so inefficient with its method)? If you don't need the general characteristics of the parameter system you may be better to save the parameters as a file (?) or even use low level FLASH methods to simply copy a large block of such parameters to a certain location in FLASH (?). Would these methods be possible or do you still prefer using 128k to save up to about 8k of parameters? (with the swap block setting).

Regards

Mark

Offline saurabh

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Extending the parameter block with my own variables
« Reply #4 on: October 01, 2009, 06:01:31 AM »
Yes I think you are right its not worthwhile to write 128 KB flash for 8 KB of user paramaters,
What i can do is, for around 1.8 K of isolated user paramaters I can use uParametersystem
(which is working), and for other array buffers (3.5 KB) I can use uFileSystem, means using
a composite approch. When these buffers changes in memory write a complete file to flash,
and retrive values to memory from flash when necessory.