How to read and write contact IC card

With the advancement of the gold card project, IC cards have been widely used in many fields including finance, transportation, social security, membership cards and so on.

The IC card (Integrated Circuit Card) is another new type of information tool that emerged after the magnetic card. In some countries and regions, IC cards are also called smart cards, smart cards, microcircuit cards or microchip cards. It is a card form in which a microelectronic chip is embedded in a card base conforming to the ISO7816 standard. The IC cards can be classified into three types according to the integrated circuits in the card.

(1) Memory card

The main application is that the integrated circuit in the card is EEPROM.

It has only data storage capabilities and no data processing capabilities. Such as:

AT24C01A, AT24C02, 93C46, AT45D041, etc.

(2) logical encryption card

The main application is that the integrated circuit in the card includes encryption logic and EEPROM. Such as: SLE4442, SLE4428, AT88SC102 and so on.

(3) CPU card

The main application is the integrated circuit in the card including CPU, EEPROM, RAM and COS (on-chip operating system) solidified in ROM.

The IC card reader is a bridge between the IC card and the application system, and is called an interface device IFD (Interface Device) in the ISO international standard. The CPU in the IFD is connected to the IC card through an interface circuit and communicates.

This article will take the AT24C01 memory card as an example to introduce how to use the M051 to control the contact IC card.

I. Overview of MuMicro M051

The N u M icro M051 series is a 32-bit microcontroller with an ARM C ortex - M 0 core. The Cortex-M0 is ARM's newest 32-bit embedded processor with the price advantage that rivals traditional 8-bit microcontrollers. The NuMicro M051 series includes M052, M054, M058 and M0516.

The NuMicro M051 core series can run up to 50MHz, making it ideal for industrial applications requiring high-speed control. The NuMicro M051 series embeds 8K/16K/32K/64K bytes of flash memory, 4kBflash for ISP, and 4kB SRAM.

Numerous system-level peripheral functions such as I/O Port, EBI (External Bus Interface), Timer, UART, SPI, I2C, PWM, ADC, Watchdog Timer, and Undervoltage Detection, built into the NuMicro M051 Series Features reduce system peripheral components, save board space and system cost, and these features make the NuMicro M051 series suitable for a wide range of applications.

At the same time, NuMicro M051 has built-in online programming function ISP and in-system programming function ICP, providing users with various programming methods. Users can upgrade the chip directly on the board.

Second, the reason for choosing M051

Wide operating voltage

Compared with other ARM series CPUs, the M051 series CPUs support a wide operating voltage (2.5~5.5V). Nowadays, a large number of IC cards on the market are 5V, thus eliminating the voltage conversion problem.

2. I/O has bidirectional function

GPIO has quasi-bidirectional function, is compatible with 8051, and operates the data I/O port of IC card, which saves the problem of selecting direction every time and simplifies the reading and writing process of IC card.

3. Larger SRAM

Compared with the ordinary 8-bit single-chip microcomputer, with larger SRAM, we can read the processing of larger data blocks and larger data blocks of the CPU card from the IC card, and the speed of data processing is correspondingly accelerated.

Third, the introduction of AT24C01 card

1. Chip characteristics

The capacity is 128×8 (1KB), two-wire serial interface (double line: clock line SCL, serial data line SDA), bidirectional data transfer protocol, support ISO/IEC7816-3 synchronization protocol, high reliability, erasing The number of times can reach 100,000 cycles, and the data retention period is 100 years.

2. Contact description of the IC card chip

The IC card chip pins, chip shock and function description are shown in Figure 1 and Table 1.



Figure 1 AT24C01 chip contact

3. Basic operation of AT24C01 card

Clock and Data Transfer: The data on SDA is only active when SCL is high, and allows data changes at low level as shown in Figure 2. When SCL is high, the change in data indicates either "start" or "stop" as shown in Figure 3. The start state and stop state are defined as follows.



Figure 2 effective timing diagram

Figure 3 start and stop status

Start state: When SCL is high, SDA transitions from high to low to indicate the start of an operation, so this state should be executed before other commands.

Stop state: When SCL is high, SDA transitioning from low to high indicates the end of an operation and will stop all communications.

Acknowledgement (ACK): After each byte of data is successfully transmitted during bus data transfer, the receiver must generate an acknowledge signal, and the responding device pulls the SDA line low during the ninth clock cycle, indicating that it has received a The 8-bit data is shown in Figure 4.



Figure 4 Data reception and confirmation


Fourth, the IC card interface schematic

This system uses NuMicro M05132-bit microcontroller to realize the interface with the IC card. It is responsible for the storage and reading of the card clock and data. It reserves the RST, FUS, PGM and other signals required by other types of IC cards. The dialing is identified by the switch on the IC card adapter socket, and the hardware interface circuit diagram is shown in FIG. 5.



Figure 5 hardware interface circuit diagram

Five, software design

Taking the read command as an example, the operation of the AT24C01 card is introduced, and the C language program is downloaded from the electronic production website.

This article uses the latest ARM Cortex-M0 core 32-bit microcontroller, which has a high cost performance. This solution has been verified on the NuTiny-SDKM051 development board.

we specialized in various of Poncho in north China, including children and adult poncho, including PVC, PE, EVA/PEVA, PU, Polyester material. According to different material, there are widely used in supermarket, promotion gift, outdoor activities, sport events, fishing etc. The color, size, printing can be customized as your request. The material and its durability are all taken into account during manufacturing stage and we take full responsibility for all the quality. 

Poncho

Poncho Raincoat,Waterproof Poncho,Plastic Ponchos,Emergency Rain Poncho

Shijiazhuang Tidy Fashion Trading Co.,Ltd , https://www.raincoatchina.com