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 PDF

Info

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
Application number
CN202011635600.7A
Other languages
Chinese (zh)
Inventor
陆春光
肖涛
宋磊
蒋紫松
冯显裕
胡斌
毛和云
李亦龙
王朝亮
刘炜
蒋群
孙钢
黄荣国
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Quzhou Power Supply Co of State Grid Zhejiang Electric Power Co Ltd
Marketing Service Center of State Grid Zhejiang Electric Power Co Ltd
Zhejiang Chint Instrument and Meter Co Ltd
Original Assignee
Quzhou Power Supply Co of State Grid Zhejiang Electric Power Co Ltd
Marketing Service Center of State Grid Zhejiang Electric Power Co Ltd
Zhejiang Chint Instrument and Meter Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Quzhou Power Supply Co of State Grid Zhejiang Electric Power Co Ltd, Marketing Service Center of State Grid Zhejiang Electric Power Co Ltd, Zhejiang Chint Instrument and Meter Co Ltd filed Critical Quzhou Power Supply Co of State Grid Zhejiang Electric Power Co Ltd
Priority to CN202011635600.7A priority Critical patent/CN112631526A/en
Publication of CN112631526A publication Critical patent/CN112631526A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal 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

Method for reading and writing same memory by main cycle and interrupt cycle of embedded system
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).
CN202011635600.7A 2020-12-31 2020-12-31 Method for reading and writing same memory by main cycle and interrupt cycle of embedded system Pending CN112631526A (en)

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)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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
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

Patent Citations (6)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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
WO2016090908A1 (en) Memory simulation testing board system and testing method for embedded application of intelligent electric meter
CN104620234A (en) Reducing latency in a peripheral component interconnect express link
CN106249840A (en) Power saving non-volatile microprocessor
CN107463459A (en) Store method, device, system and the terminal device of system exception internal storage data
CN104932954A (en) FPGA (Field Programmable Gate Array) key data protection method for microsatellite
CN201021986Y (en) Door guard reset circuit
CN102799212B (en) Global clock system for multi-core multi-processor parallel system, and application method thereof
CN112631526A (en) Method for reading and writing same memory by main cycle and interrupt cycle of embedded system
CN111323626A (en) Uncovering detection circuit integrated in MCU and uncovering detection method based on MCU
US20150377937A1 (en) Calculating Power Consumption of Electonic Devices
CN109212462A (en) A kind of fault detection method of single-phase intelligent electric energy meter residual amount exception
CN212159910U (en) MCU integrated uncapping detection circuit and electric energy meter control chip
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
CN101071404A (en) Small-capacity FIFO storage device data-moving trigger and method
CN102033823B (en) Method and device for storing data
CN116303481A (en) Storage method, device, equipment and storage medium for fault wave recording data
WO2013082625A1 (en) Method and apparatus for saving processor information prior to a reset for post reset evaluation
CN102096607B (en) Microprocessor and debugging method thereof
CN103246584A (en) Chip structure of system-on-chip and method for storing debug information
CN113742166A (en) Log recording method, device and system for server system device
CN207677833U (en) A kind of Portable acquiring equipment SIM card detection device
CN106326599B (en) System state monitoring method and device for multiprocessor system simulation

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