Embedded system demarcate when working page and refer to page switching method
Technical field
The handoff technique neck of calibration page and reference page when being adjusted the present invention relates to controller parameter in embedded system field
Domain, and in particular, to embedded system demarcate when working page and refer to page switching method.
Background technique
In the application field of many embedded systems, the controller of exploitation is often general platform, same control
Device hardware processed can be used in different project applications, and the software control function of controller is also identical, only the software of controller
Control parameter need to carry out on-line tuning according to different project, the process of optimizing and revising of this software control parameter is referred to as
Calibration needs the set of the software control parameter of on-line tuning, referred to as calibration page.In calibration, there are two types of the general of calibration page
It reads: working page and reference page.Working page is normally at RAM (Random Access Memory, random access memory) area, mark
Timing can read, modify this partial region;Reference page is normally in nonvolatile memory (such as Flash), and when calibration can only read
The value of this partial region is taken, this partial region can not be modified.In actually calibration, calibration engineering is calibration page need to be switched to work
Make page, is just able to achieve the modification to calibrating parameters a certain in working page.Currently, common chip does not have calibration page switching function
Can, only calibration special chip just supports calibration page switching.But calibration special chip value is higher, a chip is up to ten thousand easily
Member.Therefore, how to provide it is a kind of realize calibration page handoff functionality method and system be suitable for common chip be this field skill
Art personnel technical problem urgently to be resolved.
In order to solve this problem, number of patent application is entitled " a kind of realization calibration page switching of<201410432557.2>
The method and system of function " patent, propose it is a kind of all scalar quantities are changed to call by pointer, then according to calibration
When host computer to the different request instructions of working page and reference page, the address information in host computer request instruction is converted simultaneously
It is assigned to scalar quantity pointer, scalar quantity pointer is enabled to call the data information of different location.Although this method is able to solve
This problem, but the problem of programming development amount is big, and the pointer address for needing to carry out complexity is converted, easy error is brought simultaneously.With
Main core piece performance used in embedded system it is higher and higher, ram space is increasing, has better way to can solve this and asks
Topic.
Summary of the invention
The object of the present invention is to provide working page when a kind of calibration of embedded system and page switching method is referred to, this is embedded
When system calibrating working page and with reference to page switching method overcome method in the prior art solve calibration special chip value compared with
The problem of programming development amount is big, and the pointer address for needing to carry out complexity is converted, easy error is brought while high problem, is realized
Working page and reference page switching when embedded system calibration.
To achieve the goals above, working page and reference page switching side when being demarcated the present invention provides a kind of embedded system
Method, the switching method include:
Step 1, the scalar quantity data of reference page are stored in the first memory, the memory block of working page is set to second
In memory, and space phase occupied by scalar quantity data of the occupied space in memory block of the working page with the reference page
Together;
Step 2, blade-rotating in being marked in the second memory, and space occupied by the memory block of the middle blade-rotating and the work
Space occupied by the memory block of page is identical;
Step 3, in the case where embedded system initializes, by the scalar quantity data copy of reference page to the working page
Memory block in;
It step 4, is all by work for reading and writing for scalar quantity data during operation for embedded system
The scalar quantity data of the memory block of page are operated;
It is requested when host computer issues, it is desirable that when current embedded system will be switched to reference page operation, controller will first work as
Data copy in the memory block of preceding working page is into middle blade-rotating, then by reference page data copy into working page;
It is requested when host computer issues, it is desirable that when current embedded system will be switched to working page operation, controller is by transfer
Data copy with the original data of page of resuming work and is run into working page in memory block in page.
Preferably, in step 1, Nonvolatile memory is saved as in described first, it can only in the Nonvolatile memory
It reads.
Preferably, in step 1 and step 2, random access memory is saved as in described second, in random access memory
In can read and write.
Preferably, in step 1, storage address 0x0000 to 0x0FFF is divided into reference area.
Preferably, in step 1, storage address 0x6000 to 0x6FFF is divided into workspace.
Preferably, in step 2, storage address 0x7000 to 0x7FFF is divided into transfer area.
Working page and with reference to page switching method it is by above-mentioned embodiment, when embedded system calibration of the invention
Page data is either referred to the gauged address read and write always when system operation still to work page data, is all unified for
The address of working page is operated, the exchange of nominal data is realized by block copy, code is more reliable.
Other features and advantages of the present invention will the following detailed description will be given in the detailed implementation section.
Detailed description of the invention
The drawings are intended to provide a further understanding of the invention, and constitutes part of specification, with following tool
Body embodiment is used to explain the present invention together, but is not construed as limiting the invention.In the accompanying drawings:
Fig. 1 is working page and the master chip with reference to page switching method when illustrating a kind of embedded system calibration of the invention
Memory space partition structure figure;
Fig. 2 is working page and the process with reference to page switching method when illustrating a kind of embedded system calibration of the invention
Figure.
Specific embodiment
Below in conjunction with attached drawing, detailed description of the preferred embodiments.It should be understood that this place is retouched
The specific embodiment stated is merely to illustrate and explain the present invention, and is not intended to restrict the invention.
The present invention provides working page when a kind of embedded system is demarcated and refers to page switching method, which includes:
Step 1, the scalar quantity data of reference page are stored in the first memory, the memory block of working page is set to second
In memory, and space phase occupied by scalar quantity data of the occupied space in memory block of the working page with the reference page
Together;
Step 2, blade-rotating in being marked in the second memory, and space occupied by the memory block of the middle blade-rotating and the work
Space occupied by the memory block of page is identical;
Step 3, in the case where embedded system initializes, by the scalar quantity data copy of reference page to the working page
Memory block in;
It step 4, is all by work for reading and writing for scalar quantity data during operation for embedded system
The scalar quantity data of the memory block of page are operated;
It is requested when host computer issues, it is desirable that when current embedded system will be switched to reference page operation, controller will first work as
Data copy in the memory block of preceding working page is into middle blade-rotating, then by reference page data copy into working page;
It is requested when host computer issues, it is desirable that when current embedded system will be switched to working page operation, controller is by transfer
Data copy with the original data of page of resuming work and is run into working page in memory block in page.
By above-mentioned embodiment, blade-rotating in one piece is marked off, realizes the switching of the data of reference page and working page, page
Data transmission between face only needs to increase realization one piece of data block copy code, this is very easy in embedded systems
It realizes.The conversion of address pointed by all scalar quantity pointers is not needed to carry out, code development quantity is small.Always to mark when system is run
The quantitative address read and write either refers to page data and still works page data, be all unified for the address of working page into
Row operation, the exchange of nominal data is realized by block copy, and code is more reliable.
In a kind of specific embodiment of the invention, in step 1, Nonvolatile memory is saved as in described first,
It can only be read in the Nonvolatile memory.
In a kind of specific embodiment of the invention, in step 1 and step 2, arbitrary access is saved as in described second
Memory can read and write in random access memory.The present invention can make full use of the RAM memory space of chip
The switching of working page and reference page when realizing calibration.
In a kind of specific embodiment of the invention, in step 1, storage address 0x0000 to 0x0FFF is divided into
Reference area.
In this embodiment, in step 1, storage address 0x6000 to 0x6FFF is divided into workspace.
In this embodiment, in step 2, storage address 0x7000 to 0x7FFF is divided into transfer area.
Storage address 0x0000 to 0x0FFF is divided into reference area, this partial region is the section Flash, when on-line proving only
Data can be read, data cannot be written;Storage address 0x6000 to 0x6FFF is divided into workspace, this partial region is the area RAM
Between, data can be read and write;Storage address 0x7000 to 0x7FFF is divided into transfer area, this partial region is the section RAM,
Data can be read and write.
It is described the prefered embodiments of the present invention in detail above in conjunction with attached drawing, still, the present invention is not limited to above-mentioned realities
The detail in mode is applied, within the scope of the technical concept of the present invention, a variety of letters can be carried out to technical solution of the present invention
Monotropic type, these simple variants all belong to the scope of protection of the present invention.
It is further to note that specific technical features described in the above specific embodiments, in not lance
In the case where shield, can be combined in any appropriate way, in order to avoid unnecessary repetition, the present invention to it is various can
No further explanation will be given for the combination of energy.
In addition, various embodiments of the present invention can be combined randomly, as long as it is without prejudice to originally
The thought of invention, it should also be regarded as the disclosure of the present invention.