Design and implementation of IC card reader based on 89C51

Publisher:SereneNatureLatest update time:2011-05-14 Keywords:89C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Introduction

IC card is the abbreviation of Integrated Circuit Card. Some countries and regions call it Microchip Card or Microcircuit Card. The size of IC card is the same as that of magnetic card. It embeds integrated circuit on plastic card. The chip is generally a memory (ROM, EPROM.EPROM) that is not easy to lose data, a protection logic circuit, or a CPU. IC card was originally designed to solve the security problem in financial transactions. It brings a new transaction concept and huge advantages. Soon, this advantage was also noticed by other application departments, making it widely used in telephone, health care, road control and door lock control systems. As time goes by, the scope of application is still expanding, and the number of IC cards in use is growing exponentially. At the same time, in order to meet the needs of different application occasions, IC card manufacturers are still constantly launching new IC cards to the market. The price of IC cards will decrease year by year as the usage increases. All of these will undoubtedly greatly promote the popularization of IC cards in various fields. Wireless SOC development platform 499 yuan S3C44B0 ARM7 development board 378 yuan S3C2410 ARM9 development board 780 yuan AT91SAM7S64 ARM7

According to the data exchange method between IC card and reading and writing equipment, IC card can be divided into contact IC card and contactless IC card. Contact IC card is an IC card that exchanges data by directly contacting and connecting the integrated circuit of the card with the external interface device through tangible electrode contacts when in use. Contactless IC card communicates the data in the integrated circuit of the card with the external device interface device through radio waves or electromagnetic field induction. The card can read and write data without directly contacting the electrodes of the interface device. According to the function and structure of IC card, IC card can be divided into storage IC card and smart IC card. Storage IC card is passive and can only realize various input/output of data. The internal circuit of this type of IC card can be divided into two major functional parts, data storage part and data encryption operation control part. And not all IC cards must have these two functions. We call IC card with only data storage function as non-encrypted memory card (Memory Card). IC card with data storage function and data encryption operation control is called encrypted memory card (Memory Card with Security Logic). They have temporary or permanent data storage capacity, and their content can be used for processing or judgment. Smart IC card is an IC card with a microprocessor circuit in the integrated circuit of the IC card. It is an active IC card that can not only manage the I/O operations of various data and verify the personal password from the interface device, but also actively identify the interface device connected to it according to the requirements of the application system. Therefore, in the smart IC card, it is possible to establish authorization for various application systems, store relevant data of multiple application systems, and achieve high reliability and high security control of data information storage, and can perform complex information processing and calculation.

2. IC card international standards and reading and writing requirements

Since IC cards are mobile and global in use, it is particularly important to establish corresponding international and national standards. In the field of information technology, ISO (International Organization for Standardization) and IEC (International Electrotechnical Commission) jointly established a technical committee ISO/IEC JTC1 to formulate corresponding international standards. In the design of IC card application systems, every link of the reading and writing control of IC cards by the reading and writing equipment should comply with the corresponding international standards to ensure the correct reading of data. This is the basis for the design of IC card reader terminals.

Among these standards, the definition of chip and electrical characteristics and the requirements for operation timing are particularly important. Here, the electrical characteristics and timing of the synchronous card are used as an example for introduction. When using this card, the interface device puts all lines in state L, then VCC is powered on, Vpp is in idle state, CLK, RST and FCB are in state L, and the I/O of the interface device is placed in receive mode. The clock pulse is provided after t20 after the rising edge of VCC, and the duration of the clock pulse is t25. FCB remains in state L for at least t22 after the rising edge of the clock pulse. The first bit of data obtained on the I/O line can be regarded as a response, at which time CLK is in state L and is valid after t27, the falling edge of CLK. When FCB is in state H, each clock pulse is used to read the next data bit on the I/O line. In the reset response, the first clock pulse is given t24 after the rising edge of FCB. The duration of the clock pulse state H is t25, and the duration of state L is 1us (t26). The second and subsequent data bits are given at t27 after the clock is low and the CLK falling edge. The data bits are sampled sequentially with the rising edge of the clock pulse.

Design and implementation of IC card reader based on 89C51

Figure 1

3. Design of SLEE4442 interface circuit

SLE4442 is a logic encryption memory card designed by Siemens of Germany. It has a storage capacity of 2K bits and a completely independent programmable encryption code memory. The internal voltage boost circuit ensures that the chip can be powered by a single 5V voltage, and the large memory capacity can meet various requirements in the application field. It is a kind of IC card chip that is currently widely used in China. The characteristics of this chip are that it adopts a multi-memory structure; 2-wire connection protocol, the serial interface meets the ISO7816 synchronous transmission protocol; the chip adopts NMOS process technology, and the erase/write programming time per byte is 2.5ms; the memory adopts at least 10 4 erase/write cycles, and the data retention time is at least 10 years.

The main control chip of the reader is the 89C51 microcontroller. The 89C51 microcontroller is an 8-bit serial processing chip developed by Intel. It has an 8-bit CPU, 256 bytes of RAM, 21 special function registers (SFRs), 2 16-bit timers/counters, 4 8-bit parallel interfaces, a full-duplex serial interface, 5 interrupt sources and an on-chip clock oscillator. Since this is a very mature microcontroller, this article will not go into more detail.

The core module of the reader is how to achieve effective control and read-write operations on the IC chip. The design of the interface circuit directly reflects the specific operation idea of ​​the chip. Since the logic interface circuit of the IC card generally adopts an open collector (OC) output and a non-protected input structure, the source end of the pull-up resistor R is connected to the power supply of the IC card. When the IC card is in the power supply state, the entire interface circuit is connected, and a logical path is formed between the interface device and the IC card; when the IC card is in the power-off state, the source end of the pull-up resistor R loses power supply, and the entire circuit with the card interface is in a non-powered state. All IC card interface parts are added with protection diodes, which can strictly limit the voltage on each pin between -V D ~ VCC + V D (V D is the forward voltage drop of the protection diode, usually about 0.6). In this way, the instantaneous overvoltage caused by line interference and jitter on the edge of the logic level change can be suppressed, providing further protection measures for the IC card. The designed interface circuit diagram is shown in Figure 2.

Design and implementation of IC card reader based on 89C51

Figure 2 IC card control and read-write circuit

The insertion and removal of the IC card is identified by the induction switch on the IC card adapter socket. For a simple manually inserted and unplugged IC card adapter socket, this identification process is quite simple, with only one switch to indicate whether the card has been inserted. If the card has been inserted into the correct position, the IC card adapter socket will give a switch on (or off) signal, and once the card leaves this position, the signal will immediately flip. The adapter used in the design has a normally closed switch when no card is inserted, and a switch off when the card is inserted in place. For a manual IC card adapter socket, this signal is sufficient. In order to ensure that the IC card has been inserted accurately, the insertion identification process must include a de-jitter process, which is mainly implemented by software.

The address counter of most synchronous IC cards that comply with the ISO7816 standard is closely related to the clock. When the card is reset, the address counter is set to 0. Each subsequent clock beat sent to the card will add '1' to the address counter of the IC card. The upper limit of this clock frequency is 50kHz or 280kHz. The first 32 clock cycles after the reset are the reset response process of the card. During this process, the manufacturer's product code is sent one by one on the data line in a bit-coded manner, and the subsequent fields are different according to the different meanings defined by the manufacturer and the user. If a field is defined as readable, the clock can be run to the field and then read out clock by clock. The data reading process can be divided into three basic processes: reset, positioning of the data field and data reading.

4. 89C51 software module design

Since 89C51 is the main control chip, 89C51 needs to complete the reset, read and write operations of the IC chip. First of all, for the reset response operation, the reset response is carried out according to the ISO7816 standard. It can be reset at any time during the operation, and only after the reset can other operations be performed on the IC card. At the beginning, the address counter is set to 0 with a clock pulse. When the RST line is set from the H state to the L state, the content of the first data bit is sent to the I/O line. If 32 clock pulses are input continuously, the contents of the first 4 bytes of address units in the main memory are read out. At the falling edge of the 33rd clock pulse, the I/O line is set to the H state and closed. During the reset response, the "start" and "stop" states are ignored. The program design on the microcontroller is as follows:

CARD_RST:
CLR  RST
CLR  CLK
LCALL DELAY_20US
SETB  RST
LCALL DELAY_20US
SET   CLK
LCALL DELAY_20US
CLR   CLK
LCALL  DELAY_20US
CLR   RST
LCALL DELAY_20US
MOV  B,#32
RESET1:
SETB  CLK
LCALL  DELAY_20US
CLR   CLK
LCALL  DELAY_20US
DJNZ  B,RESET1
RET

在命令模式下,复位响应之后,芯片等待着命令。每条命令都以一个“启动状态”开始。整个命令包括三个字节。随后紧跟着一个附加脉冲并用一个“停止状态”来结束操作。当CLK为H状态期间,I/O线的下降沿为启动状态;当CLK为H状态期间,I/O线的上升沿为停止状态;限于篇幅,此处不再列出整个读写操作的程序代码。需要注意的是:脉冲的下降沿之后,I/O线上的第一位数据变为有效。随后每增加一个时钟脉冲,芯片内部的一位数据被送到I/O线上。其输出的顺序是从侮个字节的最低位开始。当所需要的最后一个数据送出以后,需要再附加一个时钟脉冲来把I/O线置成H状态,以便准备接受新的命令。在输出数据期间,任何“启动状态”和“停止状态”均被屏蔽掉。

5、结束语

本文的创新点是提出了一种新型的IC卡读写器设计方案,在串口通讯的设计中,除了要对单片机的异步通讯口进行操作,还要对PC 机的串口进行底层实时控制,并通过调用系统的API 函数的方法成功的解决了这一问题。由于西门子公司的SLE4442型逻辑加密IC卡是一种比较通用的IC卡芯片,因此通过更新读写器软件也可以操作其他类型的接触式同步IC一卡,使得这种接触式IC卡读写器成为一种通用的读写器。

分页
Keywords:89C51 Reference address:Design and implementation of IC card reader based on 89C51

Previous article:Application of commutation controller based on AT89C51 in periodic commutation power supply
Next article:Design of LED Color Light Controller Based on AT89C51 Single Chip Microcomputer

Recommended ReadingLatest update time:2024-11-17 00:17

Design of interface between 89C51 and ADC0809
Design the interface between 89C51 and ADC0809, collect 10 data from 2 channels, store them in the 50H~59H units of the internal RAM, and compile: (1) Delay mode; (2) Query method; (3) A program in interrupt mode. Content from the home of single-chip microcomputer www.dpj100.com Solution: The address of IN2 is 7FFAH,
[Microcontroller]
Design of serial A/D driver for 89C51 microcontroller and TLC2543 chip
The conversion result of the serial A/D converter is output in a serial manner. The serial output of digital quantities can simplify the system wiring, reduce the area of ​​the circuit board, and save system resources. The following uses TLC2543 as an example to introduce the design of the serial A/D driver. The int
[Microcontroller]
Design of serial A/D driver for 89C51 microcontroller and TLC2543 chip
Design of four-quadrant photoelectric detector
1. Principle The four-quadrant photodetector is actually composed of four photodetectors, one for each detector. The target light signal is imaged on the four-quadrant photodetector after passing through the optical system, as shown in Figure 1. The four-quadrant photodetector is generally placed on the
[Security Electronics]
Design of four-quadrant photoelectric detector
Remote granary temperature control system based on DS18B20
Introduction: This article introduces a granary temperature control system with a single-line digital temperature sensor DS18B20 as a temperature sensitive element. The system uses a microcomputer as the host computer, an 89C51 single-chip microcomputer as the detection extension, and the DS18B20 digital temperature s
[Microcontroller]
Remote granary temperature control system based on DS18B20
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号