CN112631526A - Method for reading and writing same memory by main cycle and interrupt cycle of embedded system - Google Patents
Method for reading and writing same memory by main cycle and interrupt cycle of embedded system Download PDFInfo
- Publication number
- CN112631526A CN112631526A CN202011635600.7A CN202011635600A CN112631526A CN 112631526 A CN112631526 A CN 112631526A CN 202011635600 A CN202011635600 A CN 202011635600A CN 112631526 A CN112631526 A CN 112631526A
- Authority
- CN
- China
- Prior art keywords
- cycle
- memory
- reading
- timer
- writing
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 15
- 230000006870 function Effects 0.000 abstract description 5
- 230000001960 triggered effect Effects 0.000 abstract 1
- 238000010586 diagram Methods 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 238000013459 approach Methods 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0614—Improving the reliability of storage systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0646—Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Recording Measured Values (AREA)
Abstract
The invention discloses a method for reading and writing the same memory by a main cycle and an interrupt cycle of an embedded system, and relates to the technical field of electronic electric energy meters. The waveform recording module composed of an embedded system receives waveform data of the electric energy meter and stores the waveform data in the storage device, and only the interruption write-in memory can be adopted to ensure that the data sent by the electric energy meter can be received, so that the main cycle and the interruption cycle read-write memory conflict can be caused, and the read-write function is invalid. The method comprises the following steps: a CS signal of the SPI bus triggers an interrupt receiving program, and waveform data are written into a memory in the interrupt receiving process; after the writing is finished, a timer is triggered to run, and when the 20ms period is finished, the timer is reset; in the main cycle, the timer is detected to count time, and if the time from the running of the timer to the reset is longer than the time of the reading and processing of the memory, the reading processing operation is carried out. The conflict problem of reading and writing of the same memory by the main cycle and the interrupt cycle can be effectively avoided, and the failure of the reading and writing function is prevented.
Description
Technical Field
The invention relates to the technical field of electronic electric energy meters, in particular to a method for reading and writing the same memory by a main cycle and an interrupt cycle of an embedded system.
Background
At present, with the development of a power grid demand side management technology, the local calculation function of the traditional electric energy meter cannot meet the requirements of load identification, impact load analysis and the like. To meet these requirements, recording the power grid waveform for processing by a device with greater computing power is one of the approaches. The carrier for realizing the recording of the power grid waveform is a waveform recording module consisting of an embedded system, receives waveform data from an electric energy meter and stores the waveform data in a storage device, and only can write the data into a storage device in an interrupt mode in order to ensure that the data of about 2.4k at 128 points every 20ms sent by the electric energy meter can be received. The memory data is read in the main loop of the program. This mechanism may cause memory data to be written into an interrupt while the memory data is being read, which may cause hardware resource conflicts and failure of the read and write functions.
Disclosure of Invention
The technical problem to be solved and the technical task provided by the invention are to perfect and improve the prior technical scheme, and provide a method for reading and writing the same memory by the main cycle and the interrupt cycle of the embedded system, so as to solve the conflict problem when the main cycle and the interrupt of the embedded system read and write the same memory. Therefore, the invention adopts the following technical scheme.
The method for the read-write operation of the main cycle and the interrupt cycle of the embedded system on the same memory comprises the following steps:
1) in the interruption cycle, when the electric energy meter sends waveform data to the module at intervals of 20ms, a CS signal of an SPI bus of the electric energy meter triggers and receives an interruption program;
2) writing waveform data into a memory in the process of receiving interruption, triggering a timer after the writing is finished, and resetting the timer when the 20ms period is finished;
3) setting a timer, and turning to the step 1);
4) in the main cycle, the timing time of the timer is detected;
5) if the time from the running of the timer to the resetting is longer than the time of reading and processing by the memory;
6) and 4) performing a memory reading operation, and turning to the step 4).
The main cycle can conveniently identify the read-write state of the memory in the interrupt cycle by reading and judging the time of the timer, and the main cycle executes read-write operation under the condition that the interrupt cycle does not read and write the occupied memory, thereby avoiding the conflict problem of the main cycle and the interrupt cycle on reading and writing the same memory.
Has the advantages that: the conflict problem of reading and writing of the same memory by the main cycle and the interrupt cycle can be effectively avoided, and the failure of the reading and writing function is prevented.
Drawings
FIG. 1 is a schematic flow diagram of the present invention.
Fig. 2 is a functional block diagram of the present invention.
Detailed Description
The technical scheme of the invention is further explained in detail by combining the drawings in the specification.
As shown in fig. 1, the method for performing read/write operations on the same memory by using the main cycle and the interrupt cycle of the embedded system includes the following steps:
1) in the interruption cycle, when the electric energy meter sends waveform data to the module at intervals of 20ms, a CS signal of an SPI bus of the electric energy meter triggers and receives an interruption program;
2) writing waveform data into a memory in the process of receiving interruption, triggering a timer after the writing is finished, and resetting the timer when the 20ms period is finished;
3) setting a timer, and turning to the step 1);
4) in the main cycle, the timing time of the timer is detected;
5) if the time from the running of the timer to the resetting is longer than the time of reading and processing by the memory;
6) and 4) performing a memory reading operation, and turning to the step 4).
As shown in fig. 2, the electric energy meter collects the voltage and current of the power grid and transmits the voltage and current to the wave recording module for processing through the SPI interface.
The main cycle can conveniently identify the read-write state of the memory in the interrupt cycle by reading and judging the time of the timer, and the main cycle executes read-write operation under the condition that the interrupt cycle does not read and write the occupied memory, thereby avoiding the conflict problem of the main cycle and the interrupt cycle on reading and writing the same memory.
The method for performing read/write operations on the same memory by using the main loop and the interrupt loop of the embedded system shown in fig. 1-2 is a specific embodiment of the present invention, and already embodies the outstanding substantive features and significant advances of the present invention, and the method can be modified equivalently in shape, structure and the like according to the practical use requirements and under the teaching of the present invention, and is within the scope of protection of the present solution.
Claims (1)
1. The method for the read-write operation of the main cycle and the interrupt cycle of the embedded system on the same memory is characterized by comprising the following steps:
1) in the interruption cycle, when the electric energy meter sends waveform data to the module at intervals of 20ms, a CS signal of an SPI bus of the electric energy meter triggers and receives an interruption program;
2) writing waveform data into a memory in the process of receiving interruption, triggering a timer after the writing is finished, and resetting the timer when the 20ms period is finished;
3) setting a timer, and turning to the step 1);
4) in the main cycle, the timing time of the timer is detected;
5) if the time from the running of the timer to the resetting is longer than the time of reading and processing by the memory;
6) and 4) performing a memory reading operation, and turning to the step 4).
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011635600.7A CN112631526A (en) | 2020-12-31 | 2020-12-31 | Method for reading and writing same memory by main cycle and interrupt cycle of embedded system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011635600.7A CN112631526A (en) | 2020-12-31 | 2020-12-31 | Method for reading and writing same memory by main cycle and interrupt cycle of embedded system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112631526A true CN112631526A (en) | 2021-04-09 |
Family
ID=75290508
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011635600.7A Pending CN112631526A (en) | 2020-12-31 | 2020-12-31 | Method for reading and writing same memory by main cycle and interrupt cycle of embedded system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112631526A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110988605A (en) * | 2019-12-31 | 2020-04-10 | 深圳友讯达科技股份有限公司 | Fault recording sampling system and sampling method |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080282246A1 (en) * | 2007-05-07 | 2008-11-13 | Danny Dolev | Compiler aided ticket scheduling of tasks in a computing system |
CN104795081A (en) * | 2015-04-23 | 2015-07-22 | 天脉聚源(北京)教育科技有限公司 | Method and device for reading and writing PCM data in PCM cache |
CN104794001A (en) * | 2014-01-20 | 2015-07-22 | 三菱电机株式会社 | CPU program processing method and vehicle controller using same |
CN106293009A (en) * | 2016-08-16 | 2017-01-04 | 华中科技大学 | A kind of built-in energy-saving dispatching method divided based on region |
CN106304100A (en) * | 2015-06-28 | 2017-01-04 | 上海无线通信研究中心 | A kind of many communication systems time sharing transmissions method coexisting in unlicensed frequency band |
CN111796921A (en) * | 2020-06-30 | 2020-10-20 | 西安微电子技术研究所 | Embedded multi-core operating system scheduling method, scheduling device, electronic equipment and storage medium |
-
2020
- 2020-12-31 CN CN202011635600.7A patent/CN112631526A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080282246A1 (en) * | 2007-05-07 | 2008-11-13 | Danny Dolev | Compiler aided ticket scheduling of tasks in a computing system |
CN104794001A (en) * | 2014-01-20 | 2015-07-22 | 三菱电机株式会社 | CPU program processing method and vehicle controller using same |
CN104795081A (en) * | 2015-04-23 | 2015-07-22 | 天脉聚源(北京)教育科技有限公司 | Method and device for reading and writing PCM data in PCM cache |
CN106304100A (en) * | 2015-06-28 | 2017-01-04 | 上海无线通信研究中心 | A kind of many communication systems time sharing transmissions method coexisting in unlicensed frequency band |
CN106293009A (en) * | 2016-08-16 | 2017-01-04 | 华中科技大学 | A kind of built-in energy-saving dispatching method divided based on region |
CN111796921A (en) * | 2020-06-30 | 2020-10-20 | 西安微电子技术研究所 | Embedded multi-core operating system scheduling method, scheduling device, electronic equipment and storage medium |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110988605A (en) * | 2019-12-31 | 2020-04-10 | 深圳友讯达科技股份有限公司 | Fault recording sampling system and sampling method |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101976217B (en) | Anomaly detection method and system for network processing unit | |
US6539500B1 (en) | System and method for tracing | |
CN107463459B (en) | Method, device and system for storing system abnormal memory data and terminal equipment | |
CN104620234A (en) | Reducing latency in a peripheral component interconnect express link | |
CN106249840A (en) | Power saving non-volatile microprocessor | |
CN104932954A (en) | FPGA (Field Programmable Gate Array) key data protection method for microsatellite | |
CN212159910U (en) | MCU integrated uncapping detection circuit and electric energy meter control chip | |
CN102736013B (en) | A kind of idle condition method of testing of SoC chip, system and proving installation | |
CN112631526A (en) | Method for reading and writing same memory by main cycle and interrupt cycle of embedded system | |
US20150377937A1 (en) | Calculating Power Consumption of Electonic Devices | |
CN105487953B (en) | A kind of bus performance analysis method and device | |
CN109212462A (en) | A kind of fault detection method of single-phase intelligent electric energy meter residual amount exception | |
CN116303481B (en) | Storage method, device, equipment and storage medium for fault wave recording data | |
CN103631739A (en) | Positioning analysis method for embedded system and embedded system | |
CN105068969B (en) | Single particle effect guard system and method for digital signal processing platform framework | |
CN102033823B (en) | Method and device for storing data | |
CN111291022A (en) | Data storage system based on block chain | |
EP2776930A1 (en) | Method and apparatus for saving processor information prior to a reset for post reset evaluation | |
CN102096607B (en) | Microprocessor and debugging method thereof | |
CN101814054A (en) | Instruction tracing controller for debugging microcontroller | |
CN113742166A (en) | Log recording method, device and system for server system device | |
CN114461142A (en) | Method, system, device and medium for reading and writing Flash data | |
CN207677833U (en) | A kind of Portable acquiring equipment SIM card detection device | |
CN205263795U (en) | Embedded recorder of treater machine of delaying | |
CN115826731B (en) | Sleep control method and device, storage medium and computing equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20210409 |