The iso7816 standard is a standard half-duplex interface. This module acts as the main device and controls the operation of the SIM card. The SIM card acts as the slave device and generates a response signal only in two situations:After the RST signal is received, the system sends the recognition language (ASR) and responds to the command.Therefore, as the main device, the SIM card driver module mainly performs two operations: sending RST to wait for the recognition, sending commands, and waiting for the response from the SIM card.
TX, XMT,SendTransmit
RX, RCV,ReceiveReceive
---
Recognition (answer to reset)Reset response
SimModule andSimSome protocol data needs to be exchanged for initial communication.Iso7816SpecifiedRecognitionProtocol.The ASR protocol is implemented by controlling the sim_rst signal in the sim module.
The SIM card may be in a period when sim_rst is low or sim_rstResponse Signal returned during high period. IfSim_rstMaintain high level40000ItemsSim_clkStill not received after the cycleSimCardRecognitionResponse signal, indicatingSimNo or the transmission channel is faulty..
SIM the first character of the response signal returned by the card recognition SIM whether the transmission mode is direct or reverse, this character is defined as an initial character. If SIM Returns 11011100 , indicates that the SIM card supports direct mode; if the SIM card returns 11000000 , the SIM card supports the reverse mode.
as defined, , the reset response is a series of bytes, these bytes are sent to the interface device by the card as a response to the reset command. On the I/O circuit , each byte is transmitted in an asynchronous character.
each successful reset operation causes an initial character on I/O TS, TS followed by a maximum of 32 characters :
t0 ................................................ format characters, mandatory
Ta (I) Tb (I) Tc (I) TD (I )............... interface character, optional
T1 T2... TK ....................................... historical characters, optional
TCK ............................................. detection characters, conditional
• the initial character defines the decoding protocol for all subsequent characters ..
• the format character declares the first group of interface characters and all historical characters.
• the interface characters are specified by the bitmap technology declared by the format characters.
• historical characters are specified by a number encoded in a format character.
• check characters depend on the value of T in some interface characters.
to be concise, [ts] t0 TA (I )... T1... TCK indicates the byte and the character of the transferred byte.
Example:
ASD: 3B | 6C | 0 0 | 4E 54 49 43 32 64 8 1 4A 3 0 0
Recognition-atlength: 16
SimThe module supports automatic initial character detection. WhenSimModule preparationRecognitionWhen receiving, You can first passSim_cntlRegisterICMBit sets the receiver to the initial character detection mode. ThenSimThe module automatically adjusts the receiving mode based on the received initial characters and changesSim_cntlRegister Transmission ModeICBits.
Reset
3b fa 13 00 00 81 31 Fe 45 4A 43 4f 50 34 31 56 32 32 31 96
Reset and reply to Recognition
Reset
3b fa 13 00 00 81 31 Fe 45 4A 43 4f 50 34 31 56 32 32 31 96
Reset responseRecognition
TS (the initial character) = 3B
--Indicates a forward Convention. The height is1, The low level is0, First transmitted during transmissionLSB, Last transmittedMSB
T0 (the format character) = fa
--Indicates the number of interface characters and the number of historical bytes.
----Its Height4There are severalBitIs1, Indicating that there are several subsequent Historical Characters(Historical bytes)
High4Bit= F (1 1 1)Indicates that subsequent characters exist.TA1 tb1 TC1 TD1
------------------ (TA1, tb1, TC1, TA2, tb2Is a global interface character,TC2Is a special interface character)
TA1 = 13
--Indicates an enhanced baud rate, Formula3571200/(FI/di)
--------WhereFiByTA1High4Bit(F)According to the table,DiByTA1Low4Bit(D)Query results
---- F = 01, Query the table below, thenFI = 1, 372
+ ------------- + -------- +
| F | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 |
+ ------------- + -------- +
| Fi | 372 | 372 | 558 | 744 | 1116 | 1488 | 1860 | rfu |
+ ------------- + -------- +
|Maximum clockMHz | 4 | 5 | 6 | 8 | 12 | 16 | 20 | -- |
+ ------------- + -------- +
| F | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
+ ------------- + -------- +
| Fi | rfu | 512 | 768 | 1024 | 1536 | 2048 | rfu |
+ ------------- + -------- +
|Maximum clockMHz | -- | 5 | 7.5 | 10 | 15 | 20 | -- |
+ ------------- + -------- +
---- D = 03, Query the table below, thenDI = 4
+ ------------- + -------- +
| D | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 |
+ ------------- + -------- +
| Di | rfu | 1 | 2 | 4 | 8 | 16 | 1860 | rfu |
+ ------------- + -------- +
| D | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
+ ------------- + -------- +
| Di | rfu | 512 | 768 | 1024 | 1536 | 2048 | rfu |
+ ------------- + -------- +
--------The actual baud rate is38400
Tb1 = 00
----Indicates programming currentI/VoltageP, Height2Bit indicates currentI, Low6Bit VoltageP
----High2Bit= 00, Then the programming currentIAs follows:
+ ------- + -------- +
|High2Bit| 00 | 01 | 10 | 11 |
+ ------- + -------- +
|CurrentI | 25 | 50 | rfu |
+ ------- + -------- +
----Low6Bit= 00, Then ProgrammingPThe voltage is0
TC1 = 00
----Additional protection timeN = 0
TD1 = 81
----Communication ProtocolT = 1
--------------------
NoTA2
NoTb2
NoTC2
Td2 = 31
--------------------
TA3 = Fe
Int32 = 45
NoTC3
NoTd3
4A 43 4f 50 34 31 56 32 32 31
----Is a historical byte
TCK (XOR T0-TCK) = 96Verified
ETU(Elementary time unit)
OneETUTime can be selected by the software, inIso7816The Standard specifies severalETUThe standard transmission time, where the standard time is372ItemsSim_clkClock, there are also some enhancement rate time.SimThe module supports allIso7816SpecifiedETUMode.
UseByteCharacter,ByteBy8Bit composition. The transmission of each frame is composed of the start position and character data (8Bit), check bit and stop bit, where the start bit isETU(Elementary time unit).8ItemsETUTime, the check bit occupies oneETUTime, the stop bit is high, occupies2ItemsETU.
Iso7816The Protocol also specifies a compact transmission mode, in which the stop bit only1Bit. A data frame contains11ItemsETU, You can useSim_guardRegisterRcvr11To configureSimThe module supports this transmission mode.
FIFONot a register, but written through a register., FIFOYes16*8,But the sending buffer register (Sim_xmt_buf) Yes8Bit.