[go: up one dir, main page]

CN100382038C - A Method for Realizing Auxiliary Counting in the Process of Erasing and Writing Flash of Single-chip Microcomputer - Google Patents

A Method for Realizing Auxiliary Counting in the Process of Erasing and Writing Flash of Single-chip Microcomputer Download PDF

Info

Publication number
CN100382038C
CN100382038C CNB2005100862023A CN200510086202A CN100382038C CN 100382038 C CN100382038 C CN 100382038C CN B2005100862023 A CNB2005100862023 A CN B2005100862023A CN 200510086202 A CN200510086202 A CN 200510086202A CN 100382038 C CN100382038 C CN 100382038C
Authority
CN
China
Prior art keywords
clock
counting
flash
time
compensation
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.)
Active
Application number
CNB2005100862023A
Other languages
Chinese (zh)
Other versions
CN1908905A (en
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.)
State Grid Shanghai Electric Power Co Ltd
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CNB2005100862023A priority Critical patent/CN100382038C/en
Publication of CN1908905A publication Critical patent/CN1908905A/en
Application granted granted Critical
Publication of CN100382038C publication Critical patent/CN100382038C/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Microcomputers (AREA)

Abstract

本发明涉及一种实现单片机擦写Flash过程中辅助计数的方法,用于在擦写Flash的过程中,当时钟中断被屏蔽时进行辅助计数,以提高时钟计数的准确性,其特征在于,包括:步骤一,确定时钟中断关闭后程序运行的固定时间消耗和随机时间消耗的时间;及步骤二,在程序代码中实现辅助计数补偿所述固定时间消耗和随机时间消耗。本发明的实现单片机擦写Flash过程中辅助计数的方法通过辅助计数,能够最大限度的提高时钟计数的准确性,保证需要计数判断来完成的功能的实现,增强了关闭中断时时钟计数的准确性和可靠性。

Figure 200510086202

The invention relates to a method for realizing auxiliary counting in the process of erasing and writing Flash of a single-chip microcomputer, which is used for performing auxiliary counting when clock interruption is shielded in the process of erasing and writing Flash, so as to improve the accuracy of clock counting, and is characterized in that, comprising : Step 1, determining the fixed time consumption and the random time consumption of program operation after the clock interrupt is turned off; and Step 2, implementing auxiliary counting compensation in the program code for the fixed time consumption and random time consumption. The method for realizing auxiliary counting in the process of erasing and writing Flash of the single-chip microcomputer of the present invention can improve the accuracy of clock counting to the greatest extent through auxiliary counting, ensure the realization of functions that need to be counted and judged, and enhance the accuracy of clock counting when the interrupt is turned off and reliability.

Figure 200510086202

Description

一种实现单片机擦写Flash过程中辅助计数的方法 A Method for Realizing Auxiliary Counting in the Process of Erasing and Writing Flash of Single-chip Microcomputer

技术领域 technical field

本发明涉及单片机应用领域,特别是一种在芯片擦写Flash过程中辅助计数的方法。The invention relates to the application field of single-chip microcomputers, in particular to an auxiliary counting method in the process of chip erasing and writing Flash.

背景技术 Background technique

在大型的系统应用中,由于功能比较复杂,变化频繁,使版本下载更新成为必备的功能,同时对整个的下载更新过程中的完备功能要求也越来越高,需要有较高的精度来完成整个功能。在这些功能实现中,时钟中断中计数是常见的,也是必不可少的方法之一,比如用闪灯的方式来指示当前的处理状态是一种基本的需求,实际应用中,很多系统采用了单片机进行开发,由于软件封装到单片机芯片中,同时可能没有或没能外接设备来观察软件的运行状态,同时单片机资源比较少,就需要应用闪灯的方式来判别软件运行的大概情形,比如不同的闪灯方式能够指示下载开始,下载过程中等,事实上,这也是一种常见的,必要的外在观察方法,而点灯的频率计算就是通过时钟中断次数来计数的。In large-scale system applications, due to the complex functions and frequent changes, the version download update has become a must-have function. Complete the entire function. In the implementation of these functions, counting in the clock interrupt is common and one of the essential methods. For example, it is a basic requirement to indicate the current processing status by flashing lights. In practical applications, many systems use For the development of single-chip microcomputer, since the software is packaged into the single-chip microcomputer chip, at the same time, there may be no or no external equipment to observe the running status of the software. The way of flashing lights can indicate the start of downloading, the process of downloading, etc. In fact, this is also a common and necessary external observation method, and the frequency of lighting is counted by the number of clock interruptions.

现在很多单片机分为两个区域,一个区域为Boot区,一个区域为版本区。通常Boot程序有两种用途——引导版本启动和擦写Flash,更新软件版本。在更新版本的处理过程中,各款芯片的要求不尽相同,也会在一定程度上影响到时钟中断的处理,具体说,就是有些芯片在操作Flash时要求屏蔽中断,而计数的频率依据往往是在时钟中断中进行计算,中断屏蔽后就失去了准确的时钟,也就不能够正常的计数,使需要依赖于计数实现的功能失去了运行状态判断的准确性,进而有可能使其失去原有的作用。Many single-chip microcomputers are now divided into two areas, one area is the Boot area, and the other area is the version area. Usually the Boot program has two purposes - the boot version starts and erases the Flash, and updates the software version. During the processing of the updated version, the requirements of each chip are different, which will also affect the processing of clock interrupts to a certain extent. Specifically, some chips require shielding interrupts when operating Flash, and the frequency of counting is often based on The calculation is carried out in the clock interrupt. After the interrupt is shielded, the accurate clock will be lost, and the normal counting will not be possible, so that the functions that need to rely on the counting will lose the accuracy of the operating status judgment, and may cause them to lose their originality. Some effect.

本文所涉及的实现单片机擦写Flash过程中辅助计数的方法的目的是为了保证单板擦写Flash过程中计数的基本可靠性和指示性,使用户能够根据辅助的方法补偿擦写过程中所带来的损失,从而可以最大限度的提高时钟计数的准确性,保证系统功能正常。简单的说,一般的此类应用只是用时钟中断进行计数,同时通过计数的结果进行相应的处理,一旦中断被关闭,则失去了计数依据,导致相应的功能处理出现偏差。本文中采用辅助计数来计算关闭中断的时间,补偿没有中断时所消耗的时间,从而辅助时钟中断准确的计时,保证功能实现所需时间的基本准确性。The purpose of the auxiliary counting method involved in this article is to ensure the basic reliability and indicator of counting in the process of single-board flash erasing and writing, so that users can compensate for the errors in the erasing process according to the auxiliary method. In order to maximize the accuracy of clock counting and ensure the normal function of the system. To put it simply, general applications of this type only use clock interrupts for counting, and at the same time perform corresponding processing through the counting results. Once the interrupts are turned off, the counting basis will be lost, resulting in deviations in the corresponding functional processing. In this paper, the auxiliary counting is used to calculate the time of closing the interrupt, and compensate the time consumed when there is no interrupt, so as to assist the accurate timing of the clock interrupt and ensure the basic accuracy of the time required for the function to be realized.

发明内容 Contents of the invention

本发明所要解决的技术问题在于提供一种实现单片机擦写Flash过程中计数的方法,以克服现有技术中有些单片机擦写Flash过程中不能打开时钟中断导致时钟计数不准的缺点。The technical problem to be solved by the present invention is to provide a method for counting in the process of erasing and writing the Flash with a single-chip microcomputer, so as to overcome the inaccurate shortcoming of clock counting caused by the inaccurate clock counting caused by the inability to open the clock interrupt in the process of erasing and writing the Flash of some single-chip microcomputers in the prior art.

为了实现上述目的,本发明提供了一种实现单片机擦写Flash过程中辅助计数的方法,用于在擦写Flash的过程中,当时钟中断被屏蔽时进行辅助计数,以提高时钟计数的准确性,其中,包括:In order to achieve the above object, the present invention provides a method for realizing auxiliary counting in the process of erasing and writing Flash of a single-chip microcomputer, for performing auxiliary counting when the clock interrupt is shielded in the process of erasing and writing Flash, to improve the accuracy of clock counting , including:

步骤一,确定时钟中断关闭后程序运行的固定时间消耗和随机时间消耗的时间;及Step 1, determine the fixed time consumption and the random time consumption time of the program running after the clock interrupt is turned off; and

步骤二,在程序代码中实现辅助计数补偿所述固定时间消耗和随机时间消耗。Step 2, implement auxiliary counting compensation in the program code for the fixed time consumption and the random time consumption.

所述的方法,其中,所述步骤一进一步包括:Described method, wherein, described step one further comprises:

步骤一一,分析程序代码,确定操作Flash时打开中断和关闭中断的触发点;Step one by one, analyze the program code to determine the trigger point of opening and closing the interrupt when operating the Flash;

步骤一二,分析程序代码,确定关闭中断和打开中断过程中固定的代码执行部分和随机的执行部分;Step one and two, analyze the program code, determine the fixed code execution part and the random execution part in the process of closing the interrupt and opening the interrupt;

步骤一三,分析并计算固定代码部分执行的时间T1及随机执行部分消耗的时间范围T2~T3。Step 13: Analyze and calculate the execution time T1 of the fixed code part and the time range T2-T3 consumed by the random execution part.

所述的方法,其中,在所述步骤一三中,利用示波器测量或时钟晶振计算所述固定代码部分执行的时间T1。Said method, wherein, in said step 13, use oscilloscope measurement or clock crystal oscillator to calculate the execution time T1 of said fixed code part.

所述的方法,其中,在所述步骤二中,所述实现辅助计数补偿固定时间消耗的步骤进一步包括:Said method, wherein, in said step 2, said step of implementing auxiliary counting compensation for fixed time consumption further includes:

步骤二一,操作Flash前关闭时钟中断时,备份当前时钟计数结果;Step 21, when the clock interrupt is turned off before operating the Flash, back up the current clock counting result;

步骤二二,操作Flash后打开时钟中断前,还原时钟计数结果,根据辅助计数固定损耗所得的时间T1补偿保存的计数;Step 22: Restore the counting result of the clock before turning on the clock interrupt after operating the Flash, and compensate the saved count according to the time T1 obtained by the auxiliary counting fixed loss;

步骤二三,打开一设定的用于退出所述Flash操作的中断,并在所述中断中进行计数判断,对超过计数值需要触发的功能进行处理,同时更新相应的计数值,保证计数的及时性和准确性。Step two and three, open a set interrupt for exiting the Flash operation, and count and judge in the interrupt, process the function that needs to be triggered beyond the count value, and update the corresponding count value at the same time to ensure the accuracy of the count timeliness and accuracy.

所述的方法,其中,在所述步骤二中,所述实现辅助计数补偿随机时间消耗的步骤进一步包括:Said method, wherein, in said step 2, said step of implementing auxiliary counting compensation for random time consumption further includes:

步骤三二,操作Flash后打开时钟中断前,还原时钟计数结果,取(T2+T3)/2作为补偿值,补偿关闭时钟中断后延误的随机时间消耗。Step 32: Restore the counting result of the clock and take (T2+T3)/2 as the compensation value before turning on the clock interrupt after operating the Flash to compensate for the random time consumption delayed after the clock interrupt is turned off.

所述的方法,其中,在所述步骤二中,所述实现辅助计数补偿固定时间消耗和随机时间消耗的时钟计数补偿值包括固定时间损耗T1和随机时间消耗(T2+T3)/2。Said method, wherein, in said step 2, said clock count compensation value for realizing auxiliary count compensation fixed time consumption and random time consumption includes fixed time consumption T1 and random time consumption (T2+T3)/2.

所述的方法,其中,所述步骤二三中用于退出所述Flash操作的中断为一定时器中断,且打开所述定时器中断的步骤中进一步包括根据硬件需要设定所述定时器中断的触发计数值的步骤。Described method, wherein, the interruption that is used to withdraw from described Flash operation in described step two or three is a timer interruption, and the step of opening described timer interruption further includes setting described timer interruption according to hardware needs The trigger count value of the step.

所述的方法,其中,进一步包括一Flash操作完成后进入所述定时器中断服务程序,并判断所述补偿时间是否大于设定的功能触发的计数值的步骤;如是,则触发相应功能;如否,则对所述时钟计数值进行补偿,并在补偿后打开所述关闭的时钟中断。Described method, wherein, further comprises the step of entering described timer interrupt service program after the Flash operation is finished, and judges whether described compensation time is greater than the counter value that the function trigger of setting; If so, then trigger corresponding function; If not, the clock count value is compensated, and the disabled clock interrupt is enabled after the compensation.

所述的方法,其中,在所述实现辅助计数补偿时间消耗的步骤后,进一步包括一进入正常计数的步骤。Said method, wherein, after said step of implementing auxiliary counting to compensate time consumption, further includes a step of entering normal counting.

本发明的实现单片机擦写Flash过程中辅助计数的方法通过辅助计数,能够最大限度的提高时钟计数的准确性,保证需要计数判断来完成的功能的实现,增强了关闭中断时时钟计数的准确性和可靠性。The method for realizing auxiliary counting in the process of erasing and writing Flash of the single-chip microcomputer of the present invention can improve the accuracy of clock counting to the greatest extent through auxiliary counting, ensure the realization of functions that need to be counted and judged, and enhance the accuracy of clock counting when the interrupt is turned off and reliability.

这种辅助计数补偿时钟中断延迟的方法,采用固定补偿和随机补偿来弥补擦写Flash过程中时钟中断被屏蔽后所带来的时钟计数不精确问题,提高了时钟计数的准确性,让我们可以更方便更有效的利用时钟计数来实现闪灯等有时序要求的功能,同时,由于随机补偿的存在,也决定了此方法只是能基本满足时间要求,并不能达到完全准确的辅助计数。不过,在实际应用中,基本上可以满足时间实时性的需求。This method of auxiliary counting to compensate clock interrupt delay uses fixed compensation and random compensation to make up for the inaccurate clock counting problem caused by the clock interrupt being masked in the process of erasing and writing Flash, which improves the accuracy of clock counting and allows us to It is more convenient and effective to use clock counting to realize timing-required functions such as flashing lights. At the same time, due to the existence of random compensation, this method can only basically meet the time requirements and cannot achieve completely accurate auxiliary counting. However, in practical applications, it can basically meet the real-time requirements.

本发明的方法可用于当所使用的芯片在应用过程中正常擦写Flash会影响时钟中断,但又需要基本正常的计数来完成一定功能的情况。The method of the present invention can be used in the situation that when the used chip normally erases and writes the Flash in the application process, the clock interruption will be affected, but basically normal counting is required to complete a certain function.

以下结合附图和具体实施例对本发明进行详细描述,但不作为对本发明的限定。The present invention will be described in detail below in conjunction with the accompanying drawings and specific embodiments, but not as a limitation of the present invention.

附图说明 Description of drawings

图1为本发明方法的一种实现单片机Flash动态更新的方法图;Fig. 1 is a kind of method figure that realizes single-chip microcomputer Flash dynamic update of the inventive method;

图2为本发明方法的一种实现单片机Flash动态更新的方法实施图。FIG. 2 is an implementation diagram of a method for realizing dynamic updating of a single-chip microcomputer Flash according to the method of the present invention.

具体实施方式 Detailed ways

本发明所述的方法按以下方案实现:Method of the present invention is realized according to the following scheme:

设备:单片机及其宿主单板Equipment: MCU and its host board

测试仪器:示波器等测量执行时间的仪器或无。Test Instruments: Instruments such as oscilloscopes to measure execution time or none.

辅助计数方法需要包括以下两种因素:Auxiliary counting methods need to include the following two factors:

1、时钟中断关闭后程序运行固定的时间消耗1. After the clock interrupt is turned off, the program runs for a fixed time consumption

2、时钟中断关闭后程序运行随机的时间消耗2. After the clock interrupt is turned off, the random time consumption of the program running

由上可知,辅助计数的方法中需要分别进行处理固定和随机的事件的时间消耗,具体如下:(固定时间:指固定代码执行时间T1;辅助时间:指硬件操作指令发出到完成的大概时间和代码的随即执行时间用T2~T3表示)It can be seen from the above that the method of auxiliary counting needs to process the time consumption of fixed and random events separately, as follows: (fixed time: refers to the fixed code execution time T1; auxiliary time: refers to the approximate time from the issuance of the hardware operation instruction to the completion and The random execution time of the code is represented by T2~T3)

1、确定固定时间消耗和辅助时间消耗的时间1. Determine the time of fixed time consumption and auxiliary time consumption

i.分析程序代码,确定操作Flash时打开时钟中断和关闭时钟中断的触发点。i. Analyze the program code to determine the trigger point of turning on and off the clock interrupt when operating the Flash.

ii.分析程序代码,确定关闭时钟中断和打开时钟中断过程中固定的代码执行部分和随机的执行部分。ii. Analyze the program code to determine the fixed code execution part and the random execution part in the process of closing the clock interrupt and opening the clock interrupt.

iii.计算固定代码部分执行的时间,可利用示波器测量或时钟晶振计算处理指令的时间T1。iii. To calculate the execution time of the fixed code part, an oscilloscope can be used to measure or a clock crystal oscillator can be used to calculate the time T1 of processing instructions.

iv.分析并计算随机事件消耗的时间范围T2~T3,其中该时间范围一般根据代码当前运行的环境,以及代码本身的分支情况来确定。iv. Analyze and calculate the time range T2-T3 consumed by random events, where the time range is generally determined according to the current running environment of the code and the branching situation of the code itself.

2.程序代码中实现辅助计数补偿固定损耗2. Auxiliary counting compensation for fixed loss is realized in the program code

i.操作Flash前关闭时钟中断时,备份当前时钟计数结果i. When the clock interrupt is turned off before operating the Flash, the current clock counting result is backed up

ii.操作Flash后打开时钟中断前,还原时钟计数结果,根据辅助计数固定损耗所得的时间T1补偿保存的计数ii. After operating the Flash and before turning on the clock interrupt, restore the clock counting result, and compensate the saved count according to the time T1 obtained by the auxiliary counting fixed loss

iii.打开一中断,其中,该中断设定用于退出所述Flash操作,并在中断中进行计数判断,对超过计数值需要触发的功能进行处理,同时更新相应的计数值,保证计数的及时性和准确性,其中,该中断可以是单片机的任意中断,如定时器中断,具体可根据用户自己的设置来确定。iii. Open an interrupt, wherein, the interrupt is set for exiting the Flash operation, and counting is judged in the interrupt, the function that needs to be triggered beyond the count value is processed, and the corresponding count value is updated simultaneously to ensure the timely counting and accuracy, wherein, the interrupt can be any interrupt of the single chip microcomputer, such as a timer interrupt, which can be determined according to the user's own settings.

3.程序代码中实现辅助计数补偿随机损耗3. Auxiliary counting compensation for random loss is implemented in the program code

i.对于随机损耗T2~T3部分,没有通用的方法,这里我们采用平均法,取(T2+T3)/2作为补偿值,补偿关闭时钟中断后可能延误的时间i. There is no general method for the random loss T2~T3. Here we use the average method and take (T2+T3)/2 as the compensation value to compensate for the possible delay after the clock interrupt is turned off.

ii.具体补偿方式实现同固定损耗的补偿方法。ii. The specific compensation method is the same as the compensation method for fixed loss.

下面结合附图对实现方法流程进行详细描述。The flow of the implementation method will be described in detail below in conjunction with the accompanying drawings.

如图1所示,是实现单片机Flash擦除辅助计数方法图。主要包括5个部分,首先要根据具体的单片机硬件参数和软件程序代码确定固定消耗时间T1和随机的(即辅助的)时间消耗(这个时间我们只有一个确定的范围T2~T3,具体取平均值)(步骤101);关闭中断,(步骤102),记录处理功能触发标志处理的定时器X的时钟计数值(步骤103);进行Flash读写或擦除操作(步骤104);打开用于退出Flash操作(读写或擦除)的定时器Y的中断,并根据硬件需要设定中断触发计数值(步骤105);在定时器Y的中断服务程序中,对定时器X的补偿值T1+(T2+T3)/2进行判断,如果超过计数值则触发相应功能进行处理(可多个功能),否则进行计数值的补偿,并打开X的中断,关闭Y的中断(步骤106);最后进入正常的计数流程,功能处理标志在定时器X的中断服务程序中判断(步骤107)。As shown in Figure 1, it is a diagram of the method for realizing the auxiliary counting method of the single-chip Flash erasing. It mainly includes 5 parts. First, the fixed consumption time T1 and the random (ie auxiliary) time consumption should be determined according to the specific MCU hardware parameters and software program codes (we only have a certain range T2~T3 for this time, and the specific average value is taken ) (step 101); close interrupt, (step 102), the clock count value (step 103) of the timer X that record processing function triggers mark processing; Carry out Flash read and write or erase operation (step 104); Open for exiting The interrupt of the timer Y of Flash operation (reading and writing or erasing), and set interrupt trigger count value (step 105) according to hardware needs; In the interrupt service program of timer Y, to the compensation value T1+( T2+T3)/2 to judge, if it exceeds the count value, it will trigger the corresponding function to process (multiple functions can be used), otherwise, the count value will be compensated, and the interrupt of X will be turned on, and the interrupt of Y will be turned off (step 106); finally enter In the normal counting process, the function processing flag is judged in the interrupt service routine of timer X (step 107).

如图2所示,是本发明方法的实现单片机Flash擦除辅助计数实现方法流程图。下面在移动通信系统中,以Winbond的W78LE516P单片机在单板中的应用为例具体描述一下在进行Flash擦写时如何实现辅助计数。As shown in FIG. 2 , it is a flow chart of a method for realizing the erasing auxiliary counting of a single-chip microcomputer Flash in the method of the present invention. Next, in the mobile communication system, take the application of Winbond's W78LE516P single-chip microcomputer in the single board as an example to describe in detail how to realize the auxiliary count when performing Flash erasing.

这里我们要用到单片机的两个定时器分别是0和1,定时器1用于运行灯的计数功能,定时器0用于在擦写Flash完成后,从Flash的擦写状态跳出的触发中断。Here we will use the two timers of the single chip microcomputer, which are 0 and 1 respectively. Timer 1 is used to run the counting function of the lamp, and timer 0 is used to trigger an interrupt when the flash is erased and written from the flash state. .

根据补偿的时间设定定时器1的定时精度,保证定时精度大于补偿时间,(步骤201);Set the timing precision of timer 1 according to the time of compensation, guarantee that the timing precision is greater than the compensation time, (step 201);

进入Flash擦写操作状态之前关闭定时器1中断,记录当前定时器1的当前计数值(步骤202);Close the timer 1 interrupt before entering the Flash erasing operation state, record the current count value of the current timer 1 (step 202);

启动定时器0中断,并根据单片机硬件本次Flash操作跳出时间设定中断触发时间(即定时器0的计数值)(步骤203);Start timer 0 to interrupt, and set the interrupt trigger time (i.e. the count value of timer 0) (step 203) according to this Flash operation of single-chip microcomputer hardware this time;

Flash操作完成,进入定时器0中断服务程序(步骤204);Flash operation completes, enters timer 0 interrupt service program (step 204);

进行补偿时间的判断,判断补偿时间是否大于某功能触发的计数值(步骤205);如是,则触发相应功能并清除本次定时器1的计数值(步骤206),然后转入步骤208;如否,则对定时器1的计数值进行补偿,重新启动定时器1中断(步骤207);Carry out the judgment of compensation time, judge whether the compensation time is greater than the count value (step 205) that certain function triggers; If so, then trigger corresponding function and clear the count value (step 206) of this timer 1, then proceed to step 208; No, then the count value of timer 1 is compensated, restarting timer 1 is interrupted (step 207);

进入正常计数,如果继续有Flash操作则回到步骤202继续执行(步骤208)。Enter normal counting, if continue to have Flash operation then return to step 202 and continue to execute (step 208).

本发明的实现在Flash擦写过程中辅助计数的方法,能保证在擦写Flash过程中计数的基本可靠性和指示性,可以最大限度的提高时钟计数的准确性,保证系统功能正常。The method for realizing auxiliary counting in the flash erasing process of the present invention can ensure the basic reliability and indication of counting in the erasing and writing process of the Flash, can maximize the accuracy of clock counting, and ensure the normal function of the system.

当然,本发明还可有其他多种实施例,在不背离本发明精神及其实质的情况下,熟悉本领域的技术人员当可根据本发明作出各种相应的改变和变形,但这些相应的改变和变形都应属于本发明所附的权利要求的保护范围。Of course, the present invention can also have other various embodiments, and those skilled in the art can make various corresponding changes and deformations according to the present invention without departing from the spirit and essence of the present invention, but these corresponding Changes and deformations should belong to the scope of protection of the appended claims of the present invention.

Claims (7)

1. a method that realizes auxiliary counting in the Flash erase/write process of chip microcomputer is used for the process at Flash erase/write, carries out auxiliary counting when clock interrupts conductively-closed, to improve the accuracy of clock count, it is characterized in that, comprising:
Step 1, the set time of determining program run after the clock impeding shutdown consumes time range T2~T3 that T1 and random time consume; And
Step 2 realizes that in program code auxiliary counting compensates described set time consumption and random time consumption;
The step that the described realization auxiliary counting compensation set time consumes further comprises:
Step 2 one, when closing the clock interruption before the operation Flash, backup present clock count results;
Before step 2 two, operation are opened clock behind the Flash and are interrupted, reduction clock count result, the counting of preserving according to time T 1 compensation of auxiliary counting fixed loss gained;
Step 2 three is opened one and is used to withdraw from the interruption of described Flash operation, and count judgement in described interruption, and the function that need trigger above count value is handled, and upgrades corresponding count value simultaneously;
The step of described realization auxiliary counting compensation random time consumption further comprises:
Before opening the clock interruption behind the operation Flash, reduction clock count result gets (T2+T3)/2 value by way of compensation, and the random time consumption of having no progeny in the clock and incuring loss through delay is closed in compensation.
2. method according to claim 1 is characterized in that, described step 1 further comprises:
Step one by one, the routine analyzer code is opened described clock and is interrupted and close the trigger point that described clock interrupts when determining operation Flash;
Step 1 two, the routine analyzer code is determined to close described clock interruption and is opened code operating part fixing in the described clock interrupt procedure and operating part at random;
Step 1 three, the time T 1 that analysis and calculating fixed code are partly carried out reaches the time range T2~T3 of operating part consumption at random.
3. method according to claim 2 is characterized in that, in described step 1 three, utilizes oscilloscope measurement or clock crystal oscillator to calculate the time T 1 that described fixed code is partly carried out.
4. method according to claim 1 and 2, it is characterized in that, in described step 2, the described realization auxiliary counting compensation set time consumes and the clock count offset of random time consumption comprises set time loss T1 and random time consumption (T2+T3)/2.
5. method according to claim 1, it is characterized in that, the interruption that is used to withdraw from described Flash operation in the described step 2 three is that a timer interrupts, and opens and further comprise the step of setting the flip-flop number value that described timer interrupts according to the hardware needs in the step that described timer interrupts.
6. method according to claim 5 is characterized in that, further comprises after Flash operation is finished entering described timer interrupt service routine, and judges the step of the count value whether described make-up time triggers greater than the function of setting; In this way, then trigger corresponding function; As not, then described clock count value is compensated, and after compensation, open described clock interruption of closing.
7. according to claim 1,2 or 5 described methods, it is characterized in that, after the step of described realization auxiliary counting make-up time consumption, comprise that further one enters the step of normal counting.
CNB2005100862023A 2005-08-03 2005-08-03 A Method for Realizing Auxiliary Counting in the Process of Erasing and Writing Flash of Single-chip Microcomputer Active CN100382038C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2005100862023A CN100382038C (en) 2005-08-03 2005-08-03 A Method for Realizing Auxiliary Counting in the Process of Erasing and Writing Flash of Single-chip Microcomputer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2005100862023A CN100382038C (en) 2005-08-03 2005-08-03 A Method for Realizing Auxiliary Counting in the Process of Erasing and Writing Flash of Single-chip Microcomputer

Publications (2)

Publication Number Publication Date
CN1908905A CN1908905A (en) 2007-02-07
CN100382038C true CN100382038C (en) 2008-04-16

Family

ID=37700020

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2005100862023A Active CN100382038C (en) 2005-08-03 2005-08-03 A Method for Realizing Auxiliary Counting in the Process of Erasing and Writing Flash of Single-chip Microcomputer

Country Status (1)

Country Link
CN (1) CN100382038C (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN86208674U (en) * 1986-11-11 1988-06-08 长春邮电学院 Oscillating range limiter for pointer of program counter
US5694614A (en) * 1995-02-15 1997-12-02 Ast Research, Inc. Minimum latency bus interface circuit with reduced I/O pin count through multi-mode operation
US6134698A (en) * 1998-06-17 2000-10-17 Advanced Micro Devices, Inc. Reduced pin count isochronous data bus

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN86208674U (en) * 1986-11-11 1988-06-08 长春邮电学院 Oscillating range limiter for pointer of program counter
US5694614A (en) * 1995-02-15 1997-12-02 Ast Research, Inc. Minimum latency bus interface circuit with reduced I/O pin count through multi-mode operation
US6134698A (en) * 1998-06-17 2000-10-17 Advanced Micro Devices, Inc. Reduced pin count isochronous data bus

Also Published As

Publication number Publication date
CN1908905A (en) 2007-02-07

Similar Documents

Publication Publication Date Title
Weaver Linux perf_event features and overhead
WO2021057057A1 (en) Target-code coverage testing method, system, and medium of operating system-level program
US8898049B2 (en) System level power profiling of embedded applications executing on virtual multicore system-on-chip platforms
US7506205B2 (en) Debugging system and method for use with software breakpoint
TWI235912B (en) Performance monitor system and method suitable for use in an integrated circuit
US8457943B2 (en) System and method for simulating a multiprocessor system
KR100937062B1 (en) Detecting virtualization
CN104462004A (en) Microprocessor and method for processing synchronous operation among cores
US8473921B2 (en) Debugging mechanisms in a cache-based memory isolation system
Greathouse et al. Demand-driven software race detection using hardware performance counters
US8370684B2 (en) Microprocessor with system-robust self-reset capability
CN102117243A (en) Method for high efficiently debugging by using software breakpoint in Flash memory
US7793160B1 (en) Systems and methods for tracing errors
Lai et al. Fast profiling framework and race detection for heterogeneous system
CN100382038C (en) A Method for Realizing Auxiliary Counting in the Process of Erasing and Writing Flash of Single-chip Microcomputer
CN101814054B (en) Instruction tracking controller for debugging microcontroller
CN104239275A (en) Multi-core microprocessor and reconfiguration method thereof
US9600422B2 (en) Monitoring accesses to memory in a multiprocessor system
Gupta Developing an ARM Trusted Firmware Profiler for NVIDIA Tegra
Gastel et al. Detecting energy bugs and hotspots in control software using model checking
CN104239274A (en) Microprocessor and configuration method thereof
Tong et al. Profiling CAD tools: A proposed classification
Brignon et al. Assertion-Based Verification through Binary Instrumentation
US20090222254A1 (en) System and method for integrated circuit emulation
Pohlack Runtime monitoring for open real-time systems.

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
ASS Succession or assignment of patent right

Owner name: GUANGDONG HUABO ENTERPRISE MANAGEMENT CONSULTING C

Free format text: FORMER OWNER: ZTE CORPORATION

Effective date: 20141009

C41 Transfer of patent application or patent right or utility model
COR Change of bibliographic data

Free format text: CORRECT: ADDRESS; FROM: 518057 SHENZHEN, GUANGDONG PROVINCE TO: 510640 GUANGZHOU, GUANGDONG PROVINCE

TR01 Transfer of patent right

Effective date of registration: 20141009

Address after: 510640 Guangdong city of Guangzhou province Tianhe District gold Yinglu No. 1 was 1106 room two

Patentee after: Guangdong Huabo Enterprise Management Consulting Co., Ltd.

Address before: 518057 Nanshan District science and Technology Industrial Park, Guangdong high tech Industrial Park, ZTE building

Patentee before: ZTE Corporation

ASS Succession or assignment of patent right

Owner name: STATE GRID SHANGHAI ELECTRIC POWER COMPANY

Free format text: FORMER OWNER: GUANGDONG HUABO ENTERPRISE MANAGEMENT CONSULTING CO., LTD.

Effective date: 20141126

C41 Transfer of patent application or patent right or utility model
COR Change of bibliographic data

Free format text: CORRECT: ADDRESS; FROM: 510640 GUANGZHOU, GUANGDONG PROVINCE TO: 200002 PUDONG NEW AREA, SHANGHAI

TR01 Transfer of patent right

Effective date of registration: 20141126

Address after: 200002 Shanghai City, Pudong New Area source deep road, No. 1122

Patentee after: State Grid Shanghai Municipal Electric Power Company

Address before: 510640 Guangdong city of Guangzhou province Tianhe District gold Yinglu No. 1 was 1106 room two

Patentee before: Guangdong Huabo Enterprise Management Consulting Co., Ltd.