With the continuous development of information technology, mobile phones have gradually become an indispensable tool in modern society. However, once the mobile phone is lost, the information stored in the SIM card is lost, which causes a lot of unnecessary trouble. In order to save these important information, it is very important to make the necessary backups on the computer. This article uses the GPIO port of ST7267 microcontroller to realize the reading and writing of SIM card.
1 hardware circuit design
1.1 ST7267 Microcontroller Overview
The ST7267 has a USB2.O hardware interface, and the mass storage control interface can support various types of NAND Flash. It has 54 KB of ROM and 4 KB of RAM.
1.2 SIM card interface circuit
The SIM card pin functions are defined as listed in Table 1.
The interface circuit of ST7267 MCU and SIM card is shown as in Fig. 1. The circuit mainly provides a 4MHz, stable clock frequency to the SIM card by the peripheral active crystal Y2. The power supply is output from a LDO by 3.3V, pure DC power to the Cl_VCC of the SIM card. Here, select the PE2 pin of ST7267 as the I/O pin, communicate with the SIM card through a 4.7kΩ pull-up resistor; select the PE3 pin as the reset control pin of the SIM card.
2 low-level software design
The SIM card has a different data transmission method than other memory cards, and it complies with the ISO7816 standard. Therefore, when designing the SIM card, you should pay attention to the width of each data bit during data transmission, and then write the program according to the ISO7816 standard. The first is to receive the correct reset acknowledge signal (ATR), and the second is to send a command to the SIM card to get the correct return data and status flags.
2.1 Calculation of ETU
ETU (basic time unit) is the time for inputting/outputting each bit of data on the SIM card I/O pin. The calculation formula is;
Among them: parameters F and D are clock frequency conversion factor and baud rate adjustment factor respectively, here the default rate is used, ie F=372, D=1; the used clock frequency f is 4MHz. It can be calculated that the basic time unit is 93 μs.
2.2 Basic data frame structure
The protocol used for communication is the asynchronous half-duplex character transmission protocol of T=0 as specified in ISO7816-3. The basic data frame consists of 1 start bit (low level), 8 data bits and 1 parity bit, as shown in Figure 2. Among them, the check digit is to evenly check the 8 data bits with itself, that is, the number of 1 must be even. The start bit does not perform a check operation. The SIM card and the microcontroller must be at a high level during the protection time (ie, the I/O port is high). In the T=O protocol, if the SIM card or the microcontroller detects that the parity result is incorrect, the I/O port is pulled low during the guard time to show the error.
2.3 SIM card APDU structure
Application Protocol Data Units (APDUs) include Command APDUs and Answer APDUs. The structure is as follows:
Where: CLA is the type of instruction, A0 is defined as the application of GSM; INS is the instruction code; Pl, P2, P3 are the instruction parameters, P3 indicates the length of the data; Data is the data to be transmitted; SW1 and SW2 are the commands The status returned after processing.
2.4 Design of the basic program module
Let myBit be the storage variable sampled from the I/O port, set Parity to the parity variable, and Parlty to the initialization value of 0. Every time I sample from the I/O port, myBit will perform an exclusive-OR with Parity and the result will be placed in Parity. After sampling 9 times in this way, if the final value of Parity is 0, it means that the parity is correct; if it is not 0, it means that the data reading fails, and an error message is returned, asking the sender to resend.
Delight visitors to your Garden, home or patio with our vast kingdom of both exotic and local outdoor animal statues. These exclusive creations are cast in quality designer resin and individually hand painted to mimic their wild counterparts. Create your own backyard zoo of color, whimsy and danger as you move through our cute and cuddly statues to our large and menacing statues.
Easter gifts: charming beauty, rustic charm and elegant character will bring you a lot of happiness. Walk into your room, enjoy your retro/country bunny, give yourself or your kids a happy gift, it will light up your favorite space. Whether you are curling up in the living room fire, drinking tea on the porch, or walking into the bedroom, this will be an elegant addition to your decoration and make your face full of smiles.
GIFT GIVING MADE SIMPLE: Do You Want To Give A Gorgeous Gift That Stands Out From The Rest & Is The Favorite Gift Received? Something So Fabulous & Beautiful. Know You Are Giving A Gift That Will Be So Appreciated Because Of It`s Amazing Character And Ability To Fit In With Any Room & Any Decor Style. This item Comes Wonderfully Gift-Boxed For Ease Of Giving. Show Your Love To Someone Special. It's a great gift for easter day, housewarming, wedding, Christmas etc.
Easter,Shoe Storage Box,Display Shoe Case,Small Shoe Organizer,Drawer Shoe Box
HISMOK(SHENZHEN)TECHNOLOGY CO.,LTD , https://www.willtrademat.com