JPH11282766A - Microcomputer - Google Patents

Microcomputer

Info

Publication number
JPH11282766A
JPH11282766A JP10085559A JP8555998A JPH11282766A JP H11282766 A JPH11282766 A JP H11282766A JP 10085559 A JP10085559 A JP 10085559A JP 8555998 A JP8555998 A JP 8555998A JP H11282766 A JPH11282766 A JP H11282766A
Authority
JP
Japan
Prior art keywords
data
nonvolatile memory
address
power supply
selector
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
JP10085559A
Other languages
Japanese (ja)
Inventor
Tsunehiko Tanitsu
常彦 谷津
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.)
Sanyo Electric Co Ltd
Original Assignee
Sanyo Electric 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 Sanyo Electric Co Ltd filed Critical Sanyo Electric Co Ltd
Priority to JP10085559A priority Critical patent/JPH11282766A/en
Publication of JPH11282766A publication Critical patent/JPH11282766A/en
Pending legal-status Critical Current

Links

Landscapes

  • Power Sources (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

PROBLEM TO BE SOLVED: To continue the operation immediately before a hold even after the hold irrespective of a drop in a power source voltage. SOLUTION: When hold state is entered by a drop in a power voltage VDD, data of a program counter 3, a RAM 4 and a stack pointer 5 are saved into an area, which is has not been used, of a nonvolatile memory 2 that is electrically simultaneously erasable. When the hold is released, data are read out of the nonvolatile memory 2, are set in the program counter 3, the RAM 4 and the stack pointer 5 and, a microcomputer continues to be operated from the state immediately before the hold.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、電源電圧の低下に
応じて動作がホールドされるマイクロコンピュータに関
する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a microcomputer whose operation is held in response to a decrease in power supply voltage.

【0002】[0002]

【従来の技術】一般に、マイクロコンピュータには、図
3に示すように少なくとも動作制御用のプログラムが記
憶されるマスクROMやROMのプログラムを読み出す
ためにアドレス制御するプログラムカウンタPC、デー
タが記憶されるRAM及びプログラムのメインルーチン
からサブルーチンへ移行するときメインルーチンのアド
レスを保持するスタックポインタが内蔵されている。そ
の一方で、マイクロコンピュータはホールド機能を有す
る。ホールド機能とは、電源電圧VDDが低下するとマイ
クロコンピュータのメイン動作を一時停止させ、電源電
圧VDDが復帰するとマイクロコンピュータのメイン動作
を再動作させる。マイクロコンピュータには図3のよう
に電源端子VDDにコンデンサーが接続され、電源電圧低
下時にはコンデンサーの端子電圧だけで例えば時計動作
などの最低限の動作を行わせて、マイクロコンピュータ
を完全に停止させないようにし、電源電圧が復帰したと
きにマイクロコンピュータのメイン動作を継続させる。
2. Description of the Related Art Generally, as shown in FIG. 3, a microcomputer stores a mask ROM in which at least an operation control program is stored, a program counter PC for performing address control for reading a ROM program, and data. A built-in RAM and a stack pointer for holding the address of the main routine when shifting from the main routine of the program to the subroutine. On the other hand, the microcomputer has a hold function. The hold function suspends the main operation of the microcomputer when the power supply voltage VDD decreases, and restarts the main operation of the microcomputer when the power supply voltage VDD returns. As shown in FIG. 3, a capacitor is connected to the power supply terminal VDD in the microcomputer, and when the power supply voltage drops, only the terminal voltage of the capacitor performs only a minimum operation such as a clock operation so that the microcomputer is not completely stopped. When the power supply voltage is restored, the main operation of the microcomputer is continued.

【0003】[0003]

【発明が解決しようとする課題】ところで、従来では、
電源電圧VDDが低下したとき、電源電圧VDDの低下量に
よって動作が変わる。図4アのように、電源電圧VDDの
低下が小さく、例えばデータの保持可能な電圧より高い
場合、電源電圧VDDが復帰したときデータは保持されて
いるのでマイクロコンピュータはホールド前の動作を継
続して再動作させることができる。
By the way, conventionally,
When the power supply voltage VDD decreases, the operation changes according to the amount of decrease in the power supply voltage VDD. As shown in FIG. 4A, when the drop in the power supply voltage VDD is small, for example, higher than a voltage at which data can be held, the microcomputer holds the operation before the hold because the data is held when the power supply voltage VDD returns. Can be restarted.

【0004】しかし、電源電圧VDDが図4イのようにデ
ータの保持可能な電圧より低くなると、RAM、プログ
ラムカウンタPC及びスタックポインタに記憶されたデ
ータは不定状態(図4イの期間a)になり、ホールド前
のデータを正確に保持しておくことはできない。その
為、電源電圧が復帰しても、マイクロコンピュータの動
作を継続させることができなかった。
However, when the power supply voltage VDD becomes lower than the voltage at which data can be held as shown in FIG. 4A, the data stored in the RAM, the program counter PC and the stack pointer are in an undefined state (period a in FIG. 4A). Therefore, the data before the hold cannot be held accurately. Therefore, even when the power supply voltage is restored, the operation of the microcomputer cannot be continued.

【0005】[0005]

【課題を解決するための手段】本発明によれば、電源電
圧の低下時動作をホールドするマイクロコンピュータに
おいて、電源電圧の低下に応じて所定状態の出力信号を
出力する電源電圧検出手段と、該電源電圧検出手段の出
力信号に応じて、退避させておきたいデータを一時退避
させる退避用メモリとを備えることを特徴とする。
According to the present invention, there is provided a microcomputer which holds an operation when a power supply voltage drops, a power supply voltage detecting means for outputting an output signal in a predetermined state in accordance with the power supply voltage drop, A save memory for temporarily saving data to be saved in accordance with an output signal of the power supply voltage detection means.

【0006】また、ホールドが解除されると、前記メモ
リに退避されたデータを読み出し、前記データに対応す
る回路に読み出されたデータをセットする手段を備える
ことを特徴とする。特に、前記メモリは電気的に一括消
去可能な不揮発性メモリであることを特徴とする。
[0006] Further, when the hold is released, there is provided means for reading the data saved in the memory and setting the read data in a circuit corresponding to the data. In particular, the memory is a nonvolatile memory that can be electrically erased in a batch.

【0007】さらに、前記不揮発性メモリのアドレスを
指定するアドレスカウンタと、退避させておきたいデー
タに対応する各々の回路を選択するセレクタとを備え、
指定されたアドレスへのデータ書き込み及び読み出しを
行うことを特徴とする。前記不揮発性メモリは、データ
が退避されているか否かの状態を保持するフラグを備え
ることを特徴とする。
[0007] Further, there is provided an address counter for specifying an address of the nonvolatile memory, and a selector for selecting each circuit corresponding to data to be saved,
Data writing and reading to a designated address are performed. The nonvolatile memory includes a flag for holding a state as to whether data is saved.

【0008】本発明によれば、ホールド状態になると退
避させておきたいデータをメモリに書き込み、ホールド
が解除されるとメモリからデータを読み出し各々の回路
にデータをセットするので、ホールド解除後ホールド直
前の状態から動作が継続される。
According to the present invention, the data to be saved is written to the memory when the hold state is entered, and when the hold is released, the data is read from the memory and the data is set in each circuit. The operation is continued from the state of.

【0009】[0009]

【発明の実施の形態】図1は本発明の実施の形態を示す
図である。1はマイクロコンピュータの動作を制御する
CPU、2はデータ入出力部2a及び2bとアドレス制
御部2cとフラグFRFとを含み、マイクロコンピュー
タの動作プログラムを記憶する電気的に一括消去可能な
不揮発性メモリ(フラッシュメモリ)、3は不揮発性メ
モリ2のアドレスを制御するプログラムカウンタPC、
4はデータを記憶するRAM、5はプログラムのメイン
ルーチンからサブルーチンへ移行する際メインルーチン
のプログラムカウンタPCのカウント値を保持するスタ
ックポインタ、6は不揮発性メモリ2のプログラムデー
タをプログラム命令にデコードするインストラクション
デコーダ、7は電源電圧VDDが所定レベルVrよりも高
いか低いかを検出する電源電圧検出回路、8は電源電圧
VDDのレベルを2値化するインバータ、9はインバータ
8の出力を電源電圧検出回路7の出力パルスに応じて保
持するレジスタ、10はアドレス制御部10a及びデー
タ出力部10bを含み、不揮発性メモリ2のプログラム
データを書き換えるためのプログラムが記憶されるマス
クROM、12はレジスタ9の出力roを導通させ、不
揮発性メモリ2内のフラグFRFにデータを導通させる
導通回路、13はCPU1からのアドレス信号ad2に
応じてプログラムカウンタ3、RAM4またはスタック
ポインタ5を選択するセレクタ、14はレジスタ9の出
力roに応じてデータ入出力部2aまたは2bをセレク
トするセレクタ、15はCPU2からのセレクタ信号S
L1に応じて不揮発性メモリ2またはROM10にアド
レス信号ad1をセレクトするセレクタ、16はCPU
2からのセレクタ信号SL1に応じて不揮発性メモリ2
またはROM10に出力データをセレクトするセレク
タ、17はCPU2からのセレクト信号SL2に応じて
アドレス信号ad1またはad2をセレクトするセレク
タ、18はCPU2からのセレクト信号SL2に応じて
セレクタ14または16への伝送をセレクトするセレク
タ、19は入力データIN及びセレクタ14の出力デー
タをセレクトするセレクタである。尚、プログラマブル
カウンタ3乃至レジスタ9の回路、及びすべてのセレク
タはCPU1の一部として構成されており、図1では説
明を簡単とするために上記の回路をCPU1と別回路と
した。
FIG. 1 is a diagram showing an embodiment of the present invention. 1 is a CPU for controlling the operation of the microcomputer, 2 is a non-volatile memory that includes data input / output units 2a and 2b, an address control unit 2c, and a flag FRF and stores an operation program of the microcomputer and is electrically erasable collectively. (Flash memory) 3, a program counter PC for controlling an address of the nonvolatile memory 2,
4 is a RAM for storing data, 5 is a stack pointer for holding the count value of the program counter PC of the main routine when shifting from the main routine of the program to a subroutine, and 6 is for decoding the program data of the nonvolatile memory 2 into program instructions. An instruction decoder, 7 a power supply voltage detection circuit for detecting whether the power supply voltage VDD is higher or lower than a predetermined level Vr, 8 an inverter for binarizing the level of the power supply voltage VDD, 9 a power supply voltage detection of the output of the inverter 8 A register 10 that holds a signal in accordance with an output pulse of the circuit 7 includes an address control unit 10a and a data output unit 10b, and a mask ROM in which a program for rewriting program data in the nonvolatile memory 2 is stored. The output ro is made conductive, and the A conduction circuit that conducts data to the flag FRF, 13 is a selector that selects the program counter 3, the RAM 4 or the stack pointer 5 according to the address signal ad2 from the CPU 1, and 14 is a data input / output unit 2a according to the output ro of the register 9. Or 2b, a selector for selecting 2b, and 15 a selector signal S from the CPU 2.
A selector for selecting the address signal ad1 in the nonvolatile memory 2 or the ROM 10 in accordance with L1.
2 in accordance with the selector signal SL1 from the nonvolatile memory 2
Alternatively, a selector for selecting output data to the ROM 10, a selector 17 for selecting the address signal ad1 or ad2 according to the select signal SL2 from the CPU 2, and a selector 18 for transmission to the selector 14 or 16 according to the select signal SL2 from the CPU 2. A selector 19 for selecting the selector selects the input data IN and the output data of the selector 14. Note that the circuits of the programmable counter 3 to the register 9 and all selectors are configured as a part of the CPU 1, and in FIG.

【0010】不揮発性メモリを内蔵するマイクロコンピ
ュータにおいては、このプログラム書換用のマスクRO
M1と不揮発性メモリ2とのアドレス番号は連続したア
ドレス番号で付されている。例えば、マスクROM1が
0000H〜0100Hのアドレスが付されるとする
と、不揮発性メモリ2には0101H〜FFFFHが付
される。
In a microcomputer having a built-in nonvolatile memory, a mask RO for rewriting the program is used.
The address numbers of M1 and the nonvolatile memory 2 are assigned consecutive address numbers. For example, assuming that addresses of 0000H to 0100H are assigned to the mask ROM 1, 0101H to FFFFH are assigned to the nonvolatile memory 2.

【0011】マスクROM1及び不揮発性メモリ2に書
き込まれたプログラムは動作制御用であるので、同一の
アドレッシング信号によって上記2つのメモリのアドレ
スを制御することが望ましく、加えて不揮発性メモリを
内蔵したマイクロコンピュータは、ROMやRAMを内
蔵するマイクロコンピュータのアドレス制御をそのまま
使用しているので、不揮発性メモリ2及びマスクROM
1には連続したアドレスが付されている。そうすると不
揮発性メモリ2にもアドレス0000H〜0100Hで
指定される領域が存在しており、従来では未使用領域で
あった。
Since the programs written in the mask ROM 1 and the nonvolatile memory 2 are used for operation control, it is desirable to control the addresses of the two memories by the same addressing signal. Since the computer uses the address control of a microcomputer having a built-in ROM or RAM as it is, the nonvolatile memory 2 and the mask ROM
1 is assigned a continuous address. Then, an area specified by addresses 0000H to 0100H also exists in the non-volatile memory 2, which has conventionally been an unused area.

【0012】図1のマイクロコンピュータの動作を図2
のフローチャートに基づいて説明する。マイクロコンピ
ュータに電源VDDが投入され、まず、CPU1は不揮発
性メモリ2内に設けられたフラグFRFの状態を確認す
る(S1)。フラグFRFには不揮発性メモリ2に各種
のデータが退避されているか否かにより異なる状態が書
き込まれ、「0」が書き込まれるとデータが退避されて
おり「1」が書き込まれていると退避されていないこと
を示す。尚、電源投入時にはフラグFRFが「1」の初
期状態に設定される。よって、電源が投入されてフラグ
FRFの状態「1」を最初に確認することにより初期設
定動作に移行される。初期設定動作時には、例えばプロ
グラムカウンタ3、RAM4やスタックポインタ5のデ
ータをクリアするなど、従来と同様の初期設定動作が行
われる(S2)。
FIG. 2 shows the operation of the microcomputer shown in FIG.
A description will be given based on the flowchart of FIG. When the power supply VDD is applied to the microcomputer, first, the CPU 1 checks the state of the flag FRF provided in the nonvolatile memory 2 (S1). Different states are written in the flag FRF depending on whether various data are saved in the nonvolatile memory 2, data is saved when “0” is written, and saved when “1” is written. Not indicate. When the power is turned on, the flag FRF is set to an initial state of “1”. Therefore, when the power is turned on and the state “1” of the flag FRF is first checked, the operation shifts to the initial setting operation. At the time of the initial setting operation, the same initial setting operation as in the related art is performed, for example, by clearing the data of the program counter 3, the RAM 4, and the stack pointer 5 (S2).

【0013】初期設定の終了後、マイクロコンピュータ
がホールド状態にあるか否か確認される(S3)。つま
り、電源電圧VDDが低下したか否かによって判別され
る。電源電圧VDDが所定レベルVrより低下し、所定レ
ベルVrとクロスすると、電源電圧検出回路7から所定
幅のパルスが出力される。また、電源電圧VDDが低下す
るとインバータ8からLレベルの出力が出力され、前記
パルスのタイミングでインバータ8の出力がレジスタ9
に保持される。逆に、電源電圧VDDが再び高くなり、所
定レベルVrとクロスすると、電源電圧検出回路7から
所定幅のパルスが出力されるとともに、インバータ8の
出力はHレベルとなり、レジスタ9に保持される。
After the completion of the initial setting, it is confirmed whether or not the microcomputer is in the hold state (S3). That is, it is determined whether the power supply voltage VDD has decreased. When the power supply voltage VDD falls below the predetermined level Vr and crosses the predetermined level Vr, the power supply voltage detection circuit 7 outputs a pulse having a predetermined width. When the power supply voltage VDD drops, an L-level output is output from the inverter 8, and the output of the inverter 8 is stored in the register 9 at the timing of the pulse.
Is held. Conversely, when the power supply voltage VDD rises again and crosses the predetermined level Vr, a pulse of a predetermined width is output from the power supply voltage detection circuit 7 and the output of the inverter 8 becomes H level and is held in the register 9.

【0014】電源電圧VDDが低下しないと、レジスタ9
の出力roはHレベルを維持し、CPU1はホールド状
態ではないと判別され、CPU1は通常動作を開始す
る。通常動作になると、まず、CPU1はHレベルのセ
レクト信号SL1及びSL2を出力し、セレクタ15は
アドレス信号ad1をセレクタ17の方へ出力させ、セ
レクタ16は不揮発性メモリ2の出力データをセレクト
するとともに、セレクタ17はアドレス信号ad1をセ
レクトし、セレクタ18は不揮発性メモリ2の出力デー
タをセレクタ16の方へ出力させる。このような状態で
不揮発性メモリ2に書き込まれたプログラムに従って動
作が行われる。
If the power supply voltage VDD does not decrease, the register 9
Keeps the H level, the CPU 1 is determined not to be in the hold state, and the CPU 1 starts the normal operation. In the normal operation, first, the CPU 1 outputs select signals SL1 and SL2 at H level, the selector 15 outputs the address signal ad1 to the selector 17, and the selector 16 selects the output data of the nonvolatile memory 2 and , The selector 17 selects the address signal ad1, and the selector 18 outputs the output data of the nonvolatile memory 2 to the selector 16. In such a state, the operation is performed according to the program written in the nonvolatile memory 2.

【0015】CPU1のプログラムカウンタ3のカウン
ト値がインクリメントされ、カウント値に応じてアドレ
ス信号ad1が出力される。尚、この場合のアドレス信
号ad1は不揮発性メモリ2のアドレス0101H〜F
FFFHのいずれかを指定するものである。アドレス信
号ad1はセレクタ15及び17を介して不揮発性メモ
リ2のアドレス制御部2cに入力される。アドレス信号
ad1により不揮発性メモリ2のアドレスが指定され、
プログラムデータが読み出される。プログラムデータは
データ出力部2bから出力され、セレクタ18及び16
を介してCPU1に入力され、インストラクションデコ
ーダ6でプログラム命令にデコードされ、各種動作が実
行される。その後、プログラムカウンタ3のカウント値
がインクリメントされ、不揮発性メモリ2において次の
アドレスが指定され、そのアドレスのプログラムデータ
に応じて各種命令が実行される(S4)。通常動作では
マイクロコンピュータは上記動作を繰り返すとともに、
ステップS3及びS4を繰り返すのでマイクロコンピュ
ータは電源電圧VDDの低下を監視しながら通常動作を行
う。
The count value of the program counter 3 of the CPU 1 is incremented, and an address signal ad1 is output according to the count value. In this case, the address signal ad1 is the address 0101H-F of the nonvolatile memory 2.
One of FFFH is designated. The address signal ad1 is input to the address control unit 2c of the nonvolatile memory 2 via the selectors 15 and 17. The address of the nonvolatile memory 2 is specified by the address signal ad1,
The program data is read. The program data is output from the data output unit 2b, and the selectors 18 and 16
And is decoded into a program instruction by the instruction decoder 6, and various operations are executed. Thereafter, the count value of the program counter 3 is incremented, the next address is designated in the nonvolatile memory 2, and various instructions are executed in accordance with the program data at that address (S4). In normal operation, the microcomputer repeats the above operation,
Since the steps S3 and S4 are repeated, the microcomputer performs a normal operation while monitoring the decrease of the power supply voltage VDD.

【0016】ここで、通常動作中に外部割り込みによる
データの書き換えを説明する。まずCPU1からセレク
ト信号SL1がLレベルになり、セレクタ15はアドレ
ス信号ad1をマスクROM10の方へ出力させ、セレ
クタ16はマスクROM10の出力データをセレクトす
る。その後、プログラムカウンタ3の現在のカウント値
がレジスタ(図示せず)に格納された後、プログラムカ
ウンタ3のカウント値を所定値に設定させる。これによ
り、マスクROM10用のアドレス0000H〜010
0Hのいずれかを指定するアドレス信号ad1が出力さ
れる。アドレス信号ad1は、セレクタ15を介してマ
スクROM10のアドレス制御部10aに入力される。
そして、ROM10のアドレスが指定されて、ROM1
0のプログラムデータが読み出される。プログラムデー
タはセレクタ16を介してインストラクションデコーダ
6に入力され、プログラム命令にデコードされる。さら
に、プログラムカウンタPCがインクリメントされ、R
OM10内の次のアドレスが指定される。
Here, rewriting of data by an external interrupt during normal operation will be described. First, the select signal SL1 from the CPU 1 becomes L level, the selector 15 outputs the address signal ad1 to the mask ROM 10, and the selector 16 selects the output data of the mask ROM 10. Thereafter, after the current count value of the program counter 3 is stored in a register (not shown), the count value of the program counter 3 is set to a predetermined value. Thereby, the addresses 0000H to 010 for the mask ROM 10 are set.
An address signal ad1 designating any one of 0H is output. The address signal ad1 is input to the address control unit 10a of the mask ROM 10 via the selector 15.
Then, the address of the ROM 10 is designated and the ROM 1
0 is read out. The program data is input to the instruction decoder 6 via the selector 16 and is decoded into a program instruction. Further, the program counter PC is incremented and R
The next address in the OM 10 is specified.

【0017】マスクROM10には不揮発性メモリ2の
データを書き換えるプログラムが書き込まれており、こ
のプログラムに従ってCPU1が動作する。まず、RA
M4のアドレスが指定され、書き換えるデータが読み出
される。読み出されたデータは図示されないCPU1の
レジスタに保持された後、不揮発性メモリ2のデータ入
力部2aに転送される。データ入力部2aのデータは不
揮発性メモリ2に書き込まれ、データ書換えが完了す
る。書換えが完了すると、図示されないレジスタに格納
されていた外部割込み直前のカウント値がプログラムカ
ウント3にセットされ、通常動作に戻る。尚、RAM4
のデータを不揮発性メモリ2に転送する場合は、CPU
1からのセレクト信号SL3がHレベルとなり、セレク
タ19は入力データIN14をセレクトし、不揮発性メ
モリ2に転送している。
A program for rewriting data in the nonvolatile memory 2 is written in the mask ROM 10, and the CPU 1 operates according to the program. First, RA
The address of M4 is specified, and the data to be rewritten is read. The read data is held in a register (not shown) of the CPU 1 and then transferred to the data input unit 2a of the nonvolatile memory 2. The data in the data input section 2a is written into the nonvolatile memory 2, and the data rewriting is completed. When the rewriting is completed, the count value immediately before the external interrupt stored in the register (not shown) is set to the program count 3 and the operation returns to the normal operation. In addition, RAM4
Is transferred to the nonvolatile memory 2 by the CPU.
The select signal SL3 from 1 goes high, the selector 19 selects the input data IN14 and transfers it to the nonvolatile memory 2.

【0018】ステップS3において、電源電圧VDDが低
下すると、データの退避を開始する。電源電圧VDDに応
じてレジスタ9の出力roはHレベルからLレベルにな
る。出力roがLレベルになるとセレクタ14はセレク
タ19側をセレクトするとともに、出力roが導通回路
12に入力される。また、CPU1からのセレクト信号
SL2及びSL3がLレベルになり、セレクタ17はC
PU12からのアドレス信号ad2をセレクトし、セレ
クタ18はセレクタ14側をセレクトするとともに、セ
レクタ19はセレクタ14の出力データをセレクトす
る。
In step S3, when the power supply voltage VDD decreases, data saving starts. The output ro of the register 9 changes from the H level to the L level according to the power supply voltage VDD. When the output ro becomes L level, the selector 14 selects the selector 19 side, and the output ro is input to the conduction circuit 12. Further, the select signals SL2 and SL3 from the CPU 1 become L level, and the selector 17
The address signal ad2 from the PU 12 is selected, the selector 18 selects the selector 14 side, and the selector 19 selects the output data of the selector 14.

【0019】電源電圧VDDの低下すると、CPU1内の
アドレスカウンタ1aがカウント開始し、すると、アド
レス信号ad2が出力され、セレクタ17を介してアド
レス制御部2cに入力される。アドレス信号ad2はア
ドレス0000Hから0100Hを指定するものであ
る。アドレスカウンタ1aから最初のアドレス信号00
00Hが出力され、不揮発性メモリ2のアドレス000
0Hが指定される。ところで、アドレス0000Hはフ
ラグFRFの領域として形成されるとともに、導通回路
14はアドレス0000Hが指定されたときのみデータ
「0」を入力させるものである。従って、最初のアドレ
ス信号により、フラグFRFは「0」の状態になる(S
5)。
When the power supply voltage VDD decreases, the address counter 1a in the CPU 1 starts counting, and when it does, an address signal ad2 is output and input to the address control section 2c via the selector 17. The address signal ad2 specifies addresses 0000H to 0100H. First address signal 00 from address counter 1a
00H is output and the address 000 of the nonvolatile memory 2 is output.
0H is designated. Incidentally, the address 0000H is formed as an area of the flag FRF, and the conduction circuit 14 inputs data "0" only when the address 0000H is designated. Therefore, the flag FRF is set to “0” by the first address signal (S
5).

【0020】アドレスカウンタ1aがインクリメントさ
れると、不揮発性メモリ2のアドレスが変わる。それと
ともに、アドレス信号ad2に応じてセレクタ13の選
択状態も切り換わる。即ち、不揮発性メモリ2内におい
て、データを退避させる各々の回路に対応して退避デー
タ領域が割り当てられている。例えば、プログラムカウ
ンタ3に0001番地を、RAM4に0002番地〜0
0FF番地を、スタックポインタ5に0100番地を割
り当てたとする。すると、アドレス信号ad2が000
1Hになるとセレクタ13はプログラムカウンタ3のデ
ータを選択し、不揮発性メモリ2の0001番地に書き
込まれる。アドレス信号ad2が0002Hから00F
FHになるとRAM4のデータが不揮発性メモリ2の0
001番地〜00FF番地に書き込まれ、アドレス信号
ad2が0100Hになると不揮発性メモリ2の010
0番地に書き込まれる。尚、セレクタ13はアドレス信
号ad2に応じて割り当てられた番地に対応する回路を
選択するように構成される。上記動作により、プログラ
ムカウンタ3、RAM4及びスタックポインタ5のデー
タが不揮発性メモリ9の従来では未使用だった領域に退
避されることになる(S6)。本発明のように不揮発性
メモリ2にデータを退避させることによって、不揮発性
メモリ中のデータは電源がオフされても消去されないの
で、ホールド時電源電圧VDDがどのように変化してもデ
ータが失われることはない。
When the address counter 1a is incremented, the address of the nonvolatile memory 2 changes. At the same time, the selection state of the selector 13 is also switched according to the address signal ad2. That is, in the nonvolatile memory 2, a save data area is assigned to each circuit for saving data. For example, the program counter 3 stores address 0001 and the RAM 4 stores addresses 0002 to 0.
Assume that address 0FF is assigned to the stack pointer 5 and address 0100 is assigned to the stack pointer 5. Then, the address signal ad2 becomes 000
When it becomes 1H, the selector 13 selects the data of the program counter 3 and writes the data to the address 0001 of the nonvolatile memory 2. Address signal ad2 changes from 0002H to 00F
When FH is reached, the data in RAM 4 is
The data is written to addresses 001 to 00FF, and when the address signal ad2 becomes 0100H, 010 of the nonvolatile memory 2 is read.
It is written to address 0. The selector 13 is configured to select a circuit corresponding to the address assigned according to the address signal ad2. By the above operation, the data of the program counter 3, the RAM 4, and the stack pointer 5 are saved in the area of the nonvolatile memory 9 which has not been used in the past (S6). By evacuating data to the nonvolatile memory 2 as in the present invention, data in the nonvolatile memory is not erased even when the power is turned off, so that data is lost no matter how the power supply voltage VDD changes during the hold. I will not be told.

【0021】その後、データの退避が完了すると、ホー
ルド状態に入り、マイクロコンピュータはCPU1など
のメイン動作を停止させ、時計機能などの必要最小限の
動作だけを行う(S7)。電源電圧VDDが復帰すると、
退避されていたデータを各々の回路に戻す。電源電圧V
DDの復帰によりレジスタ8の出力roがHレベルにな
り、セレクタ14はデータ出力部2b側をセレクトす
る。マイクロコンピュータ内のCPU1等が動作を再開
し、ステップS1に戻りCPU1は不揮発性メモリ2内
のフラグFRFの状態を確認する。フラグFRFの状態
は「0」であるので、各種のデータが不揮発性メモリ2
に退避されていると確認される。フラグFRFの「0」
の状態に応じてCPU1はアドレスカウンタ1aを00
01Hからカウントさせ、不揮発性メモリ2の0001
番地〜0100番地を順次指定し、退避されたデータが
読み出される。
After that, when the data saving is completed, the microcomputer enters the hold state, stops the main operation of the CPU 1 and the like, and performs only the necessary minimum operation such as the clock function (S7). When the power supply voltage VDD returns,
The saved data is returned to each circuit. Power supply voltage V
With the return of DD, the output ro of the register 8 becomes H level, and the selector 14 selects the data output unit 2b side. The operation of the CPU 1 and the like in the microcomputer is resumed, and the process returns to step S1 where the CPU 1 checks the state of the flag FRF in the nonvolatile memory 2. Since the state of the flag FRF is “0”, various data are stored in the nonvolatile memory 2.
It is confirmed that she has been evacuated. "0" of the flag FRF
CPU 1 sets the address counter 1a to 00 in accordance with the state of
01H, the 0001 of the nonvolatile memory 2 is counted.
Addresses to 0100 are sequentially designated, and the saved data is read.

【0022】初めのアドレス信号ad2に応じてセレク
タ13はプログラムカウンタ3を選択するので、読み出
されたデータがプログラムカウンタ3にセットされる。
アドレスカウンタ1aがインクリメントされ、アドレス
信号ad2が0002H〜00FFHになると、不揮発
性メモリ2の0002番地〜00FF番地のデータが読
み出される。セレクタ13がRAM4を選択するので、
読み出されたデータがRAM4に書き込まれる。さらに
インクリメントされ、アドレス信号ad2が0100H
になると、不揮発性メモリ2の0100番地のデータが
読み出される。セレクタ13はスタックポインタ5を選
択するので、読み出されたデータはスタックポインタ5
にセットされる。上記動作により、不揮発性メモリ2内
に退避されていたデータが各々の回路に戻される。(S
8)。
Since the selector 13 selects the program counter 3 in response to the first address signal ad2, the read data is set in the program counter 3.
When the address counter 1a is incremented and the address signal ad2 changes from 0002H to 00FFH, data at addresses 0002 to 00FF of the nonvolatile memory 2 is read. Since the selector 13 selects the RAM 4,
The read data is written to the RAM 4. It is further incremented and the address signal ad2 becomes 0100H
Then, the data at the address 0100 of the nonvolatile memory 2 is read. Since the selector 13 selects the stack pointer 5, the read data is stored in the stack pointer 5.
Is set to By the above operation, the data saved in the nonvolatile memory 2 is returned to each circuit. (S
8).

【0023】データ読み出し終了後、CPU1は不揮発
性メモリ2のデータを消去し(S9)、フラグ信号FL
を出力してアドレス制御部2c及び導通回路12を制御
し、不揮発性メモリ2内のフラグ領域FRFの状態を1
に設定する(S10)。次に、ステップS3に移行し、
CPU1はホールド状態か否か確認した後、通常動作に
戻る。プログラムカウンタ3、RAM4及びスタックポ
インタ5に退避されたデータがセットされてから通常動
作になるので、ホールドされる直前の動作から継続して
動作される。
After the data reading is completed, the CPU 1 erases the data in the nonvolatile memory 2 (S9), and the flag signal FL
To control the address control unit 2c and the conduction circuit 12 to change the state of the flag area FRF in the nonvolatile memory 2 to 1
Is set (S10). Next, the process proceeds to step S3,
After confirming whether or not the CPU 1 is in the hold state, the CPU 1 returns to the normal operation. Since the normal operation starts after the saved data is set in the program counter 3, the RAM 4, and the stack pointer 5, the operation is continued from the operation immediately before being held.

【0024】このように、ROM10と同一アドレスが
付され、従来は未使用状態であった不揮発性メモリ2の
0000H〜0100Hの領域にデータの退避を行うこ
とができる。尚、図1では、プログラムカウンタ3、R
AM4及びスタックポインタ5のデータをホールドさせ
ているが、ホールド状態時データを失いたくなく一時退
避させておきたいデータであれば、上記回路のデータだ
けでなく他の回路のデータを一時待避させることも可能
である。
As described above, data can be saved in the area of 0000H to 0100H of the nonvolatile memory 2 which is assigned the same address as that of the ROM 10 and is not used in the related art. In FIG. 1, the program counter 3, R
Although the data of the AM 4 and the stack pointer 5 are held, if the data is not to be lost and temporarily saved in the hold state, temporarily save not only the data of the above circuit but also the data of other circuits. Is also possible.

【0025】[0025]

【発明の効果】本発明によれば、ホールド状態になると
退避させておきたいデータを不揮発性メモリに書き込
み、ホールドが解除されるとメモリからデータを読み出
し各々の回路にデータをセットするので、ホールド解除
後ホールド直前の状態から動作が継続させることができ
る。特に、メモリとして電気的に一括消去可能な不揮発
性メモリが使用されるので、電源が遮断された状態でも
データを記憶することが可能なため、電源電圧がどのよ
うに変化してもホール直前の動作から動作を継続するこ
とができる。
According to the present invention, the data to be saved is written into the nonvolatile memory when the hold state is entered, and when the hold is released, the data is read from the memory and the data is set in each circuit. The operation can be continued from the state immediately before the hold after the release. In particular, since a non-volatile memory that can be electrically erased collectively is used as the memory, data can be stored even when the power is turned off. The operation can be continued from the operation.

【0026】また、従来では未使用状態であった不揮発
性メモリの一部領域にデータを退避させるので、不揮発
性メモリを有効に利用することができる。
Further, since data is saved in a part of the nonvolatile memory which has not been used in the related art, the nonvolatile memory can be effectively used.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本発明の実施の形態を示すブロック図である。FIG. 1 is a block diagram showing an embodiment of the present invention.

【図2】図1の動作を示すフローチャートである。FIG. 2 is a flowchart showing the operation of FIG.

【図3】従来例を示すブロック図である。FIG. 3 is a block diagram showing a conventional example.

【図4】図3の動作を説明するための特性図である。FIG. 4 is a characteristic diagram for explaining the operation of FIG. 3;

【符号の説明】[Explanation of symbols]

1 CPU 2 不揮発性メモリ 3 プログラムカウンタ 4 RAM 5 スタックポインタ 6 インストラクションデコーダ 7 電源電圧検出回路 8 インバータ 9 レジスタ 10 マスクROM 12 導通回路 13〜19 セレクタ DESCRIPTION OF SYMBOLS 1 CPU 2 Non-volatile memory 3 Program counter 4 RAM 5 Stack pointer 6 Instruction decoder 7 Power supply voltage detection circuit 8 Inverter 9 Register 10 Mask ROM 12 Conduction circuit 13 to 19 Selector

Claims (5)

【特許請求の範囲】[Claims] 【請求項1】 電源電圧の低下時動作をホールドするマ
イクロコンピュータにおいて、 プログラムデータが書き込まれ、電気的に一括消去可能
な不揮発性メモリと、該不揮発性メモリのプログラムを
書きかえるためのプログラムが書き込まれるとともに、
前記不揮発性メモリの特定アドレスと同一のアドレスが
付されたROMとを含み、 さらに、電源電圧の低下に応じて所定状態の出力信号を
出力する電源電圧検出手段と、 該電源電圧検出手段の出力信号に応じて、退避させてお
きたいデータを前記不揮発性メモリの特定アドレス領域
に一時退避させる退避手段とを備えることを特徴とする
マイクロコンピュータ。
1. A microcomputer for holding an operation when a power supply voltage drops, in which a nonvolatile memory in which program data is written and electrically erasable collectively and a program for rewriting a program in the nonvolatile memory are written. Along with
A ROM provided with the same address as the specific address of the nonvolatile memory; and a power supply voltage detecting means for outputting an output signal in a predetermined state in response to a decrease in the power supply voltage; A microcomputer comprising: a save unit for temporarily saving data to be saved in a specific address area of the nonvolatile memory in accordance with a signal.
【請求項2】 前記不揮発性メモリ及びROMに付され
た同一アドレスに対して、通常動作時前記ROMのアド
レスを選択し、退避時に前記不揮発性メモリのアドレス
を選択する第1セレクタ手段を備えることを特徴とする
請求項1記載のマイクロコンピュータ。
2. The apparatus according to claim 1, further comprising: first selector means for selecting an address of the ROM during a normal operation and selecting an address of the nonvolatile memory at the time of evacuation for the same address assigned to the nonvolatile memory and the ROM. 2. The microcomputer according to claim 1, wherein:
【請求項3】 ホールドが解除されると、前記不揮発性
メモリの特定アドレス領域に退避されたデータを読み出
し、前記データに対応する回路に読み出されたデータを
セットする手段を備えることを特徴とする請求項1また
は2記載のマイクロコンピュータ。
3. When the hold is released, there is provided means for reading data saved in a specific address area of the nonvolatile memory and setting the read data in a circuit corresponding to the data. 3. The microcomputer according to claim 1, wherein
【請求項4】 さらに、前記不揮発性メモリのアドレス
を指定するためのアドレス信号に基づいて、退避させて
おきたいデータに対応する各々の回路を選択する第2セ
レクタ手段とを備え、選択された回路に対応する所定領
域のアドレスへのデータ書き込み及び読み出しを行うこ
とを特徴とする請求項3記載のマイクロコンピュータ。
And a second selector for selecting a circuit corresponding to data to be saved based on an address signal for designating an address of the nonvolatile memory. 4. The microcomputer according to claim 3, wherein data is written to and read from an address in a predetermined area corresponding to the circuit.
【請求項5】 前記不揮発性メモリは、データが退避さ
れているか否かの状態を保持するフラグを備えることを
特徴とする請求項2記載のマイクロコンピュータ。
5. The microcomputer according to claim 2, wherein the nonvolatile memory includes a flag for holding a state as to whether data is saved.
JP10085559A 1998-03-31 1998-03-31 Microcomputer Pending JPH11282766A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP10085559A JPH11282766A (en) 1998-03-31 1998-03-31 Microcomputer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP10085559A JPH11282766A (en) 1998-03-31 1998-03-31 Microcomputer

Publications (1)

Publication Number Publication Date
JPH11282766A true JPH11282766A (en) 1999-10-15

Family

ID=13862182

Family Applications (1)

Application Number Title Priority Date Filing Date
JP10085559A Pending JPH11282766A (en) 1998-03-31 1998-03-31 Microcomputer

Country Status (1)

Country Link
JP (1) JPH11282766A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010204701A (en) * 2009-02-27 2010-09-16 Rohm Co Ltd Data processor

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010204701A (en) * 2009-02-27 2010-09-16 Rohm Co Ltd Data processor

Similar Documents

Publication Publication Date Title
US5327531A (en) Data processing system including corrupt flash ROM recovery
EP0554917B1 (en) Digital signal processing system having two instruction memories accessed by a processor under control of host
JPH08202626A (en) Memory controller
US4667285A (en) Microcomputer unit
JPH11282766A (en) Microcomputer
JP2710890B2 (en) Memory designation controller
KR19980054349A (en) Optional automatic setting circuit
US7191323B2 (en) Information processing unit selecting one of reset vector addresses
US5619714A (en) Microcomputer having an instruction decoder with a fixed area and a rewritable area
JPH06236695A (en) Non-volatile memory device with exchange display function
JPH11282585A (en) Microcomputer
JPH01290040A (en) Digital signal switching circuit
EP0714060B1 (en) One chip microcomputer with built-in non-volatile memory
JP2000020498A (en) Microcomputer and its restoring method
JPH11231965A (en) Microcomputer
JPH08185354A (en) Memory managing device
US6327222B1 (en) Electronic watch
JPH05128882A (en) Data processing device
JPH0520474A (en) One chip microcomputer
JP3691137B2 (en) Microcomputer with built-in nonvolatile memory
JPH11184833A (en) Discrimination method for write termination of microcomputer
JP2959299B2 (en) Status display circuit
JP3223160B2 (en) Microcomputer
JPH11231966A (en) Microcomputer
JPH11353153A (en) Register setting circuit