We know that od ( object dictionary ) is the core of CANopen , all functions are carried out around it, is the data center of the protocol stack, good od implementation is the basis of efficient and stable operation of the protocol stack, and the basic point of OD implementation is how to save it. Because OD content is miscellaneous, read-write property, read-only data, writing-only data, can read and write data, storage requirements on the non-perishable and loss of power lost two types, data type has character, Integer, long integer, etc., the storage format has 8 bits , Position, and so on. Other than that, this article now only discusses how to use the SCM resources to try to meet the requirements of OD storage.
Does anyone think this is going to be discussed? Read-only is placed in the read-only memory, can be written in the RAM , the need to power off the storage is placed in non-volatile read-write memory. That said, but in fact a lot of problems, listed as follows:
1. read-only to the protocol stack does not represent read-only to the application.
2. data that can be read and written and stored in power-down cannot be placed in RAM .
3. frequently read-write data cannot be placed in nonvolatile memory because nonvolatile memory tends to be slow and write-times limited.
4. SCM Resource is limited, access mode and read and write speed limited value, so it is reasonable to use.
Since we have these problems, we first analyze and classify the OD data:
1. system read-only parameters. From the node factory will not need to change, for example, the node hardware serial number, software and hardware version.
2. the process data object. Frequent reading and writing, power-down without saving. For example, the amount of analog to be collected, the number of switches to be output.
3. System configuration parameters. Read-write, occasional configuration, most of the time.
Basically, all OD objects can be grouped into these three categories. Then the AVR MCU as an example of the several types of SCM storage resources and its characteristics:
|
Type |
Read-write properties in Run |
Access speed |
Capacity |
Characteristics |
FLASH |
Program Memory |
Read-only |
So so |
Larger |
Easy to operate but only program and initialize read-only data, no loss of power |
Sram |
Data memory |
Write |
The fastest |
Small |
Easy operation, fast speed, loss of power-down data |
Eeprom |
Data memory |
Write |
Read in general, write very slowly |
Small |
Complex operation, very slow writing speed |
See the above table, you will immediately put the three types of OD data storage location, the system read-only parameters in FLASH , the process data objects in SRAM , System configuration parameters in the EEPROM .
It's really the way it should be, but all the problems are solved? no,no,no! How does the data object in OD be arranged into the memory? How does the system boot initialize? How to access? A scenario is provided below:
Factory settings are written with the programFLASH, and then the system starts to run, during the software initialization process, the program will factory default the entireODObject fromFLASHLoaded intoRAMTo go, whether it isODAnd then if the judgment is to run for the first time, theRAMThe type of data that belongs to the system configuration parameter to initializeEEPROM, otherwise withEEPROMIn the system configuration parameters to re-overwrite the correspondingRAMImage. Okay, initialization is complete, start running, because all of theODData areLoadToRAMIn, soODcan provide a unified and fast data service interface, external read operation is directly readRAM, write is write firstRAMImage, and then judge if it isODSystem configuration Parameters the same class is updated at the same timeEEPROM。 The last thing to note is thatODInformation such as object properties must be placed in theFLASH, otherwise it would be a greatRAMOverhead.
The above scheme has the advantage of providing a unified and fast >od : ' Times New Roman '; " >od Access interface, can store non-volatile data in time, and can restore the factory settings on the software without adding additional factory settings backup space in eeprom a flag on the line, think of ) . Obvious advantages also mean obvious shortcomings, is to occupy more ram space, read-only data and non-volatile data are mapped to ram , which would make the original tense od content is generally not much, and now
The above scheme also applies to other single-chip microcomputer, basically now the microcontroller has Flash and RAM, and even if some MCU does not have EEPROM, but its own flash The area is can be run in-line write, or can be used as EEPROM ( but at this time it is best not to write a one, because FLASH is the page erase, compared to time, it is recommended to make a batch write method,OD 0x1010 and 0x1011 objects are involved ), it is not possible to expand outside.
(As of 2007.11.08)
Old paper Backup: How to use the memory resources on the MCU to realize the storage and access of OD