The composition of the flash variable and the flash Timer

Source: Internet
Author: User
composition of the flash variable and flash count
due to restrictions on the number of Flash writes and the write erasure wait time, flash variables and flash counters are difficult to construct.
because '0' cannot be changed to '1', The Flash variable cannot be located on a storage unit address.
Similarly, flash counters are the same.

after careful analysis of "Flash secondary writing technology", it is not difficult to see that if you make some changes, you can implement real Flash variables and flash counters.

the counter is set to +/-1 every time it is encountered. Why can't one bit be cleared to "counter ???
flash generally has a large space and is erased in almost all sectors.

assume that the flash counter is 8 bits, that is, 0 ~ 255, 256/8 = 32 bytes can be allocated as the "Flash timer", namely:
0xff, 0xff ....., 0xff indicates 0x00
0xfe, 0xff ....., 0xff indicates 0x01
0xfc, 0xff ....., 0xff indicates 0x02
...........................
0x00, 0xff ....., 0xff indicates 0x07
0x00, 0xfe ....., 0xff indicates 0x08
0x00, 0xfc ....., 0xff indicates 0x09
...........................
0x00, 0x00 ....., 0xff indicates 0x0f
...........................
0x00, 0x00 ....., 0x00 indicates 0xff

for flash variables, the address must be rewritten at a time based on the principle of address + 1. Number of incoming requests ".
it is generally used in combination with the flash timer, that is, the flash timer is actually a "Write Pointer" of the flash variable ".
when "Write count" is full, the sector where the flash counter and flash variable are located is cleared.

note that the flash counter should be read to ram after initialization !!!
When writing the flash variable, you must also update the flash counter to prevent power loss before reading the value of the flash counter into RAM.

generally, when a flash variable is used for infrequent rewriting, you must read the flash variable into RAM if you need to rewrite it frequently.

that is, the instance is running in Ram, And the instance is powered on or in flash.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.