AN204738 F²MC-8FX Family MB95200 Series 8-Bit Microcontroller Electronic Safe Demo Reference Solution.pdf

AN204738
F²MC-8FX Family MB95200 Series 8-Bit Microcontroller Electronic Safe Demo
Reference Solution
Associated Part Family: MB95200 Series
This application note describes the components and features of the Electronic Safe Demo set.
Contents
1
2
3
4
1
Overview ..................................................................... 1
Demo Platform............................................................. 2
2.1 Platform............................................................... 2
Features ...................................................................... 3
3.1 Multiple Password Level ..................................... 3
3.2 Alterable Code Length ........................................ 3
3.3 Operation Indication and Error Alarm .................. 3
3.4 Low Battery Capacity Alarm ................................ 3
3.5 Error Lock ........................................................... 3
3.6 Dual Power Supply Source ................................. 3
Functions ..................................................................... 4
4.1 How to open the Safe ......................................... 4
4.2 Main Code Operation .......................................... 5
4.3 User Code Operation .......................................... 5
4.4 Emergency Code ................................................ 6
5 Hardware ..................................................................... 7
5.1 System Block ...................................................... 7
5.2 Modules .............................................................. 9
6 Firmware ................................................................... 12
6.1 Flow Chart of Main Function ............................. 12
6.2 Firmware Project ............................................... 13
7 More Information ....................................................... 14
Document History............................................................ 15
Overview
Cypress Electronic Safe demo set which is based on Cypress MB95200 series is a high cost-effective solution.
It consists of the components below:




1 x main board with a MB95F214K
1 x 12-key keyboard
1 x electronic valve
1 x battery case for 4×5# batteries
This demo set supports these features:






Multiple password levels
Alterable code length
Operation and error indications
Low battery capacity alarm
Error lock
Dual power supplies
www.cypress.com
Document No. 002-04738 Rev. *A
1
MB95200 Series Electronic Safe Demo Reference Solution
2
Demo Platform
2.1
Platform
The electronic safe system consists of a main board which is combined with a 12-key board, an electronic valve and
a battery case for 4 × 5# batteries.
Figure 1. Front of Electronic Safe Demo
www.cypress.com
Document No. 002-04738 Rev.*A
2
MB95200 Series Electronic Safe Demo Reference Solution
3
Features
3.1
Multiple Password Level
The password has three levels of code: main code, user code and emergency code. They are ranked by priority from
high to low. Each code is used independently.
3.2
Alterable Code Length
The code length is compatible from 6 to 12 bits.
3.3
Operation Indication and Error Alarm
In this system, a buzzer is used to indicate the operations or errors. When different keys are pressed or error occurs,
the buzzer sounds differently to indicate the corresponding status.
3.4
1.
100ms on at 1 KHZ means key press.
2.
1s on at 500 HZ means correct operation.
3.
4 times of 100 ms on at 250 HZ and 50 ms off means incorrect operation.
4.
100ms on at 1 KHZ and 50 ms off in every 5 minutes means being in 15-minute-lock.
Low Battery Capacity Alarm
A LED is used to indicate the battery capacity.
3.5
1.
Normal – LED keeps on.
2.
Low – LED flashes at the frequency of 500 HZ continually.
Error Lock
The Safe will lock automatically for 30 seconds when enter an incorrect password 5 times or less, while when an
incorrect password is entered for more than 5 times, the Safe will be locked for 15 minutes.
3.6
Dual Power Supply Source
When low battery capacity occurs, the power supply will shift to a backup battery package automatically. User can
open the Safe to replace the main batteries first.
www.cypress.com
Document No. 002-04738 Rev.*A
3
MB95200 Series Electronic Safe Demo Reference Solution
4
Functions
The Safe keeps sleeping until being waked up by pressing * or PU1, Figure 2 shows the back of the demo. PU1 and
PU2 can be found on the back. In wake-up mode, an interval of longer than 5 seconds between two key-presses will
switch the Safe to sleep mode. The main functions of this electronic Safe will be introduced as follow.
Figure 2. Back of Electronic Safe Demo
PU2
PU1
4.1
How to open the Safe
The Safe have three levels of password. When the Safe is powered on, user can enter a password according to the
format below to open it.
1.
Press [*].
2.
Enter [password].
3.
Press [#].
Example: [*] 123456 [#].
www.cypress.com
Document No. 002-04738 Rev.*A
4
MB95200 Series Electronic Safe Demo Reference Solution
4.2
Main Code Operation
Condition: The Safe has been opened by main code.
4.2.1
Set main code
1. Press [*].
2.
Enter [5][3].
3.
Press [PU2].
4.
Enter [main code] [#] twice.
Example: [*] [5][3] [PU2] [543210] [#] [543210] [#].
4.2.2
Modify main code
1. Press [*].
2.
Press [0].
3.
Press [PU1].
4.
Enter [old main code] [#].
5.
Enter [new main code] [#] twice.
Example: [*] [0] [PU1] [012345] [#] [543210] [#] [543210] [#].
4.3
User Code Operation
Condition: The Safe has been opened by main code or User code
4.3.1
Set user code
1. Press [PU1].
2.
Enter [user code][#] twice.
Example: [PU1] [543210] [#] [543210] [#].
4.3.2
Modify user code
1. Press [*].
2.
Press [1].
3.
Press [PU1].
4.
Enter [old user code] [#].
5.
Enter [new user code] [#] twice.
Example: [*] [1] [PU1] [012345] [#] [543210] [#] [543210] [#].
www.cypress.com
Document No. 002-04738 Rev.*A
5
MB95200 Series Electronic Safe Demo Reference Solution
4.4
Emergency Code
Condition: The Safe has been opened by main code or Emergency code.
4.4.1
Set emergency code
1. Press [*].
2.
Enter [5][2].
3.
Press [PU2].
4.
Enter [emergency code][#] twice.
Example: [*] [5][2] [012345] [#] [012345] [#] .
4.4.2
Modify emergency code
1. Press [*].
2.
Press [8].
3.
Press [PU1].
4.
Enter [old emergency code] [#].
5.
Enter [new emergency code] [#] twice.
Example: [*] [8] [PU1] [012345] [#] [543210] [#] [543210] [#].
4.4.3
Cancel emergency code
1. Press [*].
2.
Press [8].
3.
Press [PU2].
4.
Enter [1234567890] [#].
Example: [*] [8] [PU2] [1234567890] [#].
www.cypress.com
Document No. 002-04738 Rev.*A
6
MB95200 Series Electronic Safe Demo Reference Solution
5
Hardware
5.1
System Block
The whole system consists of 7 blocks:







MCU
Key input
Electronic valve driver
Power interface
EEPROM
Battery capacity monitoring and alarm
Buzzer
A system block diagram is shown in Figure 3.
Figure 3. System Block Diagram
Keyboar
d
LED
alarm
MB95F214K
Battery
capacity
monitor
Valve
EEPRO
M
In this demo, many functions share the same pin and completed perfectly.
Please refer to Figure 4 for details (see next page).
www.cypress.com
Document No. 002-04738 Rev.*A
7
MB95200 Series Electronic Safe Demo Reference Solution
Figure 4. Electronic Safe
www.cypress.com
Document No. 002-04738 Rev.*A
8
MB95200 Series Electronic Safe Demo Reference Solution
5.2
Modules

MCU
The MCU is MB95F214K, an 8 pins IC with 16 K bytes FLASH, 496 bytes RAM and 5 general I/Os.
Figure 5. MCU
Table 1. Pin Function
Number

Pin
Direction
Function
4
RSTX/PF2
OUTPUT
Electronic valve drive
5
P04/INT04/AN04/HCLK1/EC0
INPUT
Key input, E2 SDA pin
6
P05/AN05/TO00/HCLK2
INPUT
Battery capacity monitoring,E2 SCL pin
7
P06/INT06/TO01
OUTPUT
Buzzer output
8
P12/EC0/DBG
OUTPUT
Battery capacity monitoring enable, LED
Power interface
The demo has two power supplies. When the LED flashes to indicate low battery capacity, a backup battery
package will work. User can open the Safe to replace the 5# batteries. D1 and D2 are used to prevent the
counter current.
Figure 6. Power Interface
www.cypress.com
Document No. 002-04738 Rev.*A
9
MB95200 Series Electronic Safe Demo Reference Solution

Key input
The key scan is implemented via only one AD channel. When MCU is sleeping, the pin acts as a general I/O to
monitor the high-to-low eagle from key input that will produce an interrupt to wake the MCU up. After being
waked up, the pin will be set to analog input for scanning keys.
Figure 7. Key Input
www.cypress.com
Document No. 002-04738 Rev.*A
10
MB95200 Series Electronic Safe Demo Reference Solution

EEPROM
The EEPROM shares pins with the key input and battery capacity monitoring. When the EEPROM is enabled,
the pins act as I/O, otherwise they act as analog input. The EEPROM is used to store the passwords. For an
unused Safe, the default passwords are 123456.
Figure 8. EEPROM

Battery capacity monitoring and alarm
This part has two functions. One is to control the LED, and another is to monitor the battery capacity. DPEN
controls the whole circuit. When DPEN is set as 1, the circuit work, otherwise the circuit is disabled to save
power. DEPWR is used to detect the battery capacity.
Figure 9. Battery Capacity Monitoring and Alarm
www.cypress.com
Document No. 002-04738 Rev.*A
11
MB95200 Series Electronic Safe Demo Reference Solution
6
Firmware
6.1
Flow Chart of Main Function
Here, the flow chart of main function is given for reference.
Figure 10. Main Function
Start
Initialize MCU
Load E2
N
First
power-on?
Y
Initialize
password a
write into E2
Sleep
Waked up by
key interrupt
Valid input?
N
Y
Operations
Error alarm
Check battery
capacity
www.cypress.com
Document No. 002-04738 Rev.*A
12
MB95200 Series Electronic Safe Demo Reference Solution
When routine starts, initialize the MCU first, then get the information of the Safe: is it a new Safe? If it is, a default
password will be set and written into the external EEPROM; otherwise the password will be loaded from EEPROM.
Then the Safe enters into sleep mode to save power till a key interrupt comes. In wake-up mode, if password was
input, the safe will check the validity. If the input is valid, execute according operation, or Error alarm. Checking the
battery capacity is the last function that will be executed every time. In the end, the Safe enters sleep mode.
6.2
Firmware Project
A table was given to explain the function of the main files below.
Table 2. Functions
Files
Function
safe01.c
Initialize MCU and do main loop
battery.c
Monitor battery capacity
beep.c
Buzzer
CMD.c
Switch internal modes
EEPRM24xx.c
Write or read EEROM
led.c
Led functions
key.c
Sample AD for key input
MCUinit .c
Initialize MCU
globe.c interrupt.c header.c
base timer subroutines
startup.asm
start files, just load for use
vector.c
vector configuration file
mb95200.asm
memory define, just load for use
Figure 11 is a project opened by SOFTUNE.
Figure 11. Firmware Project
Initialization
and main loop
www.cypress.com
Document No. 002-04738 Rev.*A
13
MB95200 Series Electronic Safe Demo Reference Solution
7
More Information
For more information on Cypress MB95200 products, please visit following website:
http://www.cypress.com/MB95200
www.cypress.com
Document No. 002-04738 Rev.*A
14
MB95200 Series Electronic Safe Demo Reference Solution
Document History
Document Title: AN204738 – F²MC-8FX Family MB95200 Series 8-Bit Microcontroller Electronic Safe Demo Reference
Solution
Document Number: 002-04738
Revision
ECN
Orig. of
Change
Submission
Date
**
-
HUAL
11/04/2009
Original version
*A
5235199
HUAL
05/18/2016
Migrated Spansion Application Note MCU-AN- 500056-E-10 to Cypress format.
www.cypress.com
Description of Change
Document No. 002-04738 Rev.*A
15
MB95200 Series Electronic Safe Demo Reference Solution
Worldwide Sales and Design Support
Cypress maintains a worldwide network of offices, solution centers, manufacturer’s representatives, and distributors. To find
the office closest to you, visit us at Cypress Locations.
PSoC® Solutions
Products
ARM® Cortex® Microcontrollers
cypress.com/arm
PSoC 1 | PSoC 3 | PSoC 4 | PSoC 5LP
Automotive
cypress.com/automotive
Cypress Developer Community
Clocks & Buffers
cypress.com/clocks
Interface
cypress.com/interface
Lighting & Power Control
cypress.com/powerpsoc
Memory
cypress.com/memory
PSoC
cypress.com/psoc
Touch Sensing
cypress.com/touch
USB Controllers
cypress.com/usb
Wireless/RF
cypress.com/wireless
Forums | Projects | Videos | Blogs | Training | Components
Technical Support
cypress.com/support
PSoC is a registered trademark and PSoC Creator is a trademark of Cypress Semiconductor Corporation. All other trademarks or registered trademarks
referenced herein are the property of their respective owners.
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone
Fax
Website
: 408-943-2600
: 408-943-4730
: www.cypress.com
© Cypress Semiconductor Corporation, 2009-2016. This document is the property of Cypress Semiconductor Corporation and its subsidiaries, including
Spansion LLC (“Cypress”). This document, including any software or firmware included or referenced in this document (“Software”), is owned by
Cypress under the intellectual property laws and treaties of the United States and other countries worldwide. Cypress reserves all rights under such
laws and treaties and does not, except as specifically stated in this paragraph, grant any license under its patents, copyrights, trademarks, or other
intellectual property rights. If the Software is not accompanied by a license agreement and you do not otherwise have a written agreement with
Cypress governing the use of the Software, then Cypress hereby grants you a personal, non-exclusive, nontransferable license (without the right to
sublicense) (1) under its copyright rights in the Software (a) for Software provided in source code form, to modify and reproduce the Software solely for
use with Cypress hardware products, only internally within your organization, and (b) to distribute the Software in binary code form externally to end
users (either directly or indirectly through resellers and distributors), solely for use on Cypress hardware product units, and (2) under those claims of
Cypress’s patents that are infringed by the Software (as provided by Cypress, unmodified) to make, use, distribute, and import the Software solely for
use with Cypress hardware products. Any other use, reproduction, modification, translation, or compilation of the Software is prohibited.
TO THE EXTENT PERMITTED BY APPLICABLE LAW, CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD
TO THIS DOCUMENT OR ANY SOFTWARE OR ACCOMPANYING HARDWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. To the extent permitted by applicable law, Cypress reserves the right to
make changes to this document without further notice. Cypress does not assume any liability arising out of the application or use of any product or
circuit described in this document. Any information provided in this document, including any sample design information or programming code, is
provided only for reference purposes. It is the responsibility of the user of this document to properly design, program, and test the functionality and
safety of any application made of this information and any resulting product. Cypress products are not designed, intended, or authorized for use as
critical components in systems designed or intended for the operation of weapons, weapons systems, nuclear installations, life-support devices or
systems, other medical devices or systems (including resuscitation equipment and surgical implants), pollution control or hazardous substances
management, or other uses where the failure of the device or system could cause personal injury, death, or property damage (“Unintended Uses”). A
critical component is any component of a device or system whose failure to perform can be reasonably expected to cause the failure of the device or
system, or to affect its safety or effectiveness. Cypress is not liable, in whole or in part, and you shall and hereby do release Cypress from any claim,
damage, or other liability arising from or related to all Unintended Uses of Cypress products. You shall indemnify and hold Cypress harmless from and
against all claims, costs, damages, and other liabilities, including claims for personal injury or death, arising from or related to any Unintended Uses of
Cypress products.
Cypress, the Cypress logo, Spansion, the Spansion logo, and combinations thereof, PSoC, CapSense, EZ-USB, F-RAM, and Traveo are trademarks or
registered trademarks of Cypress in the United States and other countries. For a more complete list of Cypress trademarks, visit cypress.com. Other
names and brands may be claimed as property of their respective owners.
www.cypress.com
Document No. 002-04738 Rev.*A
16