Added Remark on “Refresh the interface status”
command
Advanced Card Systems Ltd. `Page 2 of 46
INDEX
Index .................................................................................................................................................... 3
This document describes the contactless part (PICC & PCD) of the ACR1222U reader only.
HIGHTLIGHTS
The ACR1222U is a dual-interface reader (IFD and PCD) that supports both contact (ICC) and
contactless (PICC) smart cards.
• One standard ICC landing type card acceptor.
• One SAM socket is provided for highly secure applications.
• A built-in antenna for PICC contactless access applications.
• ISO 7816 Parts 1-4 Compliant for Contact Smart Card Interface.
• Intelligent Support for Hybrid Cards and Combi Cards.
• Energy saving modes for turning off the antenna field whenever the PICC is inactive, or no
PICC is found. It prevents the PICC from exposing to the field all the time.
• Contactless interface Support ISO14443 Part 4 Type A & B, MIFARE, FeliCa and NFC-1
tags.
• User-Controllable Peripherals. E.g. LED, Buzzer.
• CCID Compliant.
• PCSC Compliant for Contact, Contactless and SAM Interfaces.
• USB V2.0 Interface. (12M bps)
• Device Firmware Upgradeable through the USB Interface.
Advanced Card Systems Ltd. Page 5 of 46
TERMS
•IFD: Interface Device. A terminal, communication device, or machine to which the
integrated circuit(s) card is electrically connected during operation.
• PCD: Proximity Coupling Device. ISO 14443 Contactless Reader.
• ICC: Integrated Circuit(s) Card. Refer to a plastic card containing an integrated circuit,
which is compatible with ISO 7816.
• SAM: Security Access Module, similar to ICC but in smaller size.
• PICC: Proximity Integrated Circuit(s) Card. Contactless Cards operating without
mechanical contact to the IFD, using magnetic coupling.
•Combi-Card: A smart card that supports both ICC and PICC Interfaces. But only one
interface can be operating at any one time.
•Hybrid-Card: A smart card that consists of both ICC and PICC cards. Both ICC and PICC
cards can be operating at the same time.
• USB: Universal Serial Bus, a common device interface used in PC environment.
• CCID: The specifications for USB devices that interface with ICC or act as interfaces with
ICC/PICC.
•PCSC: Personal Computer Smart Card, a specification that can facilitate the interoperability
necessary to allow ICC/PICC technology to be effectively utilized in the PC environment.
• ISO 7816: A standard for contact smart cards (ICC).
• T=0: Character-oriented asynchronous half duplex transmission protocol for ICCs (ISO
7816).
• T=1: Block-oriented asynchronous half duplex transmission protocol for ICCs (ISO 7816).
• ISO 14443: A standard for contactless smart cards (PICC)
• T=CL: Block-oriented asynchronous half duplex transmission protocol for PICCs (ISO
14443).
• APDU: Application Protocol Data Unit.
• ATR: Answer-to-Reset. The transmission sent by an ICC to the reader (IFD) in response to
a RESET condition.
•ATS: Answer-to-Select. The transmission sent by a PICC Type A to the reader (PCD) in
response to a SELECT condition.
•ATQB: Answer-to-Request. The transmission sent by a PICC Type B to the reader (PCD)
in response to a REQUEST condition.
• Card Insertion Event: Either an ICC or a PICC is just appeared to the reader.
• Card Removal Event: Either an ICC or a PICC is removed from the reader.
Advanced Card Systems Ltd. Page 6 of 46
QUICK OVERVIEW OF THE ACR1222U READER
1. ACR1222U (with Contact Card Option)
2. ACR1222U (without Contact Card Option)
Advanced Card Systems Ltd. `Page 7 of 46
3. ACR1222U ICC Interface
4. ACR1222U PICC Interface
Advanced Card Systems Ltd. `Page 8 of 46
5. ACR1222U SAM Interface
Step 1: Open the plastic covers by unscrewing the four screws first
Step 2: The SAM socket is inside the reader.
Advanced Card Systems Ltd. `Page 9 of 46
6. ACR1222U Firmware Upgrade Procedure
Step 1: Unplug the USB Cable from the PC.
Step 2: Open the plastic covers by unscrewing the four screws first.
The Button Used For Firmware Upgrade
Advanced Card Systems Ltd. `Page 10 of 46
Step 3: Insert the USB plug to USB Port before pressing the button.
Step 4: The USB Mass Storage Device can be found in Device Manager.
Step 5: Execute the Firmware Upgrade Program:
“FW Upgrade Tool.exe”
Advanced Card Systems Ltd. `Page 11 of 46
Step 6: Pressing the “Load BIN” Button.
Select the “Firmware” file for Upload to the Reader
Step 7: Pressing the “Start Program” Button.
Start Program
The firmware is being uploaded to the reader
Advanced Card Systems Ltd. `Page 12 of 46
The firmware upgrade is completed.
Step 8: Close the plastic covers. After that, reconnect the USB cord.
Noted:
If the upgrade firmware “fail”, please repeat do from steps 3 to 7.
Advanced Card Systems Ltd. `Page 13 of 46
SYSTEM DESCRIPTION
1. The Reader Block Diagram
Advanced Card Systems Ltd. Page 14 of 46
PICC
2. Communication between the PCSC Driver and the ICC, PICC & SAM
PCSC
Driver
ACR1222U
PCSC SAM
ACR1222U
PCSC ICC
ACR1222U
PCSC PICC
ACR1222U
ICCs
and
Advanced Card Systems Ltd. Page 15 of 46
3. Smart Card Readers Interfaces Overview.
Advanced Card Systems Ltd. Page 16 of 46
HARDWARE DESCRIPTION
1.LED Indicatior
The LEDs are used for showing the state of the contact and contactless interfaces.The Red LED is
used for showing PICC status and Green LED for ICC.
Reader States Red LED
1. No PICC Found or PICC present but not
activated.
PICC Indicator
A single pulse per
~ 5 seconds
Green LED
ICC Indicator
2. PICC is present and activated ON
3. PICC is operating Blinking
4. ICC is present and activated ON
5. ICC is absent or not activated OFF
6. ICC is operating Blinking
2. Buzzer
A monotone buzzer is used to show the “Card Insertion” and “Card Removal” events.
Events Buzzer
1. The reader powered up and initialization
success.
2. Card Insertion Event (ICC or PICC) Beep
3. Card Removal Event (ICC or PICC) Beep
Beep
Advanced Card Systems Ltd. Page 17 of 46
3. USB Interface
The ACR1222U is connected to a computer through USB interface as specified in the USB
Specification 2.0. The ACR1222U is working in full speed mode, i.e. 12 Mbps.
USB Interface Wiring
Pin Signal Function
1 V
BUS
+5V power supply for the reader (~200mA)
2 D-
3 D+
4 GND
Differential signal transmits data between ACR1222U and PC.
Differential signal transmits data between ACR1222U and PC.
Reference voltage level for power supply
NOTE - In order for the ACR1222U functioning properly through USB interface, ACS
proprietary device drive has to be installed. Please refer to the Device Driver Installation Guide for
more details. {VID = 0x072F; PID = 0x1280}
4. ICC Interface (Contact Smart Card)
A landing type Smart Card Acceptor is used for providing reliable operations. The minimum life
cycle of the acceptor is about 300K times of card insertion and removal.
5. SAM Interface (Contact Smart Card)
One SAM socket is provided for highly secure application requirement.
6. PICC Interface (Contactless Smart Card)
A built-in antenna is used for communication between the PCD and PICC.
Advanced Card Systems Ltd. Page 18 of 46
SOFTWARE DESCRIPTION
1.TAPDUDemoCard Demo App
This program is used to demonstrate the PCSC functions of the ACR1222U readers.
OperatingProcedures:
1) Place a PICC on the top of the ACR1222U reader.
2) Press “1. Select Reader” and select the “ACR1222 PICC Interface”
3) Select “T1” in the connection-protocol. Press “2. Connect “to establish a connection
between the card and reader.
4) Enter the APDU in text box “Message to the card”
5) Press “3. Transmit” to send the APDU to the card.
6) Press “4. Disconnect” to terminate the connection between the card and reader.
Remarks:
The program can be used to test all the PCSC interfaces. E.g. ACR1222U ICC or SAM Interface.
Advanced Card Systems Ltd. Page 19 of 46
2. ACR1222U PCSC Direct Command Test
This program is used to demonstrate the PCSC Escape functions of the ACR1222U readers.
OperatingProcedures:
1. Select the “ACS ACR1222 SAM Interface 0”.
2. Select the “Shared Mode” if a SAM is inserted or “Direct Mode if no Sam is inserted.
3. Press the button “Connect” to establish a connection between the PC and the
ACR1222U reader.
4. Enter “
2079” in the Command Text Box.
5. Enter the PCSC Escape Command, e.g. “21 01 8F” and press the button “Send” to send
the command to the reader.
6. Press the button “Disconnect” to break the connection.
Hints: “21 01 8F” is used for setting the LED and Buzzer Behaviors.
Remarks:
The program can be used to test all the PCSC interfaces. E.g. ACR1222U ICC or PICC
Interface.
Advanced Card Systems Ltd. `Page 20 of 46
PERIPHERALS CONTROL
The reader’s peripherals control is implemented by Escape Command.
If you want to enjoy the silent environment, just set the CMD value to “87”.
Advanced Card Systems Ltd. Page 22 of 46
To show the activation status of the
ICC interface.
1 = Enable; 0 =Disable
1 = Enable; 0 =Disable
PICC interface
1 = Enable; 0 =Disable
To make a beep whenever a card
insertion or removal event is
detected. (For both ICC and PICC)
1 = Enable; 0 =Disabled
To blink the LED whenever the card
(PICC or ICC) is being accessed.
Command = {2D 01 “Interfaces to be refreshed”}
Response = {E1 00 00 00 01 “Interfaces refreshed”}
<Interface No>
Bit 0 = ICC Interface
Bit 1 = PICC Interface
Bit 2 = SAM Interface
Hints: This command is useful for refreshing the SAM status after a new SAM is inserted.
(* Only Can Use if have SAM inserted before Power-up the reader*)
Example 1. Refresh the SAM status after a new SAM is inserted
Step 1. Connect the “SAM Interface” in “Direct” connection mode.
Step 2. Send the direct command “2D 01 04”
Step 3. Disconnect the “SAM Interface”
Step 4. Connect the “SAM Interface: again in either “Direct” or “Shared” connection mode.
Example 2. Refresh the ICC status (Reset the ICC)
Step 1. Connect the “SAM Interface” in “Direct” or “Shared” connection mode.
Step 2. Send the direct command “2D 01 01”
only TD1 is following.
Lower nibble N is the number of historical
bytes (HistByte 0 to HistByte N-1)
only TD2 is following.
Lower nibble 0 means T = 0
TD3 following.
Lower nibble 1 means T = 1
80 T1 Category indicator byte, 80 means A status
indicator may be present in an optional
COMPACT-TLV data object
4F Tk Application identifier Presence Indicator
0C Length
RID Registered Application Provider Identifier
(RID) # A0 00 00 03 06
SS Byte for standard
C0 .. C1 Bytes for card name
00 00 00 00
RFU RFU # 00 00 00 00
Advanced Card Systems Ltd. Page 25 of 46
1.2 ATR format for ISO 14443 Part 4 PICCs.
Byte
Value
(Hex)
Designation Description
0 3B Initial Header
1 8N T0 Higher nibble 8 means: no TA1, TB1, TC1
only TD1 is following.
Lower nibble N is the number of historical
bytes (HistByte 0 to HistByte N-1)
2 80 TD1 Higher nibble 8 means: no TA2, TB2, TC2
only TD2 is following.
Lower nibble 0 means T = 0
3 01 TD2 Higher nibble 0 means no TA3, TB3, TC3,
TD3 following.
Lower nibble 1 means T = 1
4
to
3 + N
XX T1 Historical Bytes:
XX
XX
XX
Tk
ISO14443A:
The historical bytes from ATS response. Refer
to the ISO14443-4 specification.
ISO14443B:
The higher layer response from the ATTRIB
response (ATQB). Refer to the ISO14443-3
specification.
4+N UU TCK Exclusive-oring of all the bytes T0 to Tk
E.g 1. ATR for DESFire = { 3B 81 80 01 80 80 } // 6 bytes of ATR
Hint: Use the APDU “FF CA 01 00 00” to distinguish the ISO14443A-4 and ISO14443B-4 PICCs,
and retrieve the full ATS if available. ISO14443A-3 or ISO14443B-3/4 PICCs do have ATS
returned.
E.g 2. ATR for ST19XRC8E = { 3B 8C 80 01 50 12 23 45 56 12 53 54 4E 33 81 C3 55}
// 12 bytes of ATQB, No CRC-B
ATQB = {50 12 23 45 56 12 53 54 4E 33 81 C3}
Advanced Card Systems Ltd. `Page 26 of 46
PSEUDO APDUS FOR CONTACTLESS INTERFACE
ACR1222U comes with two primitive commands for this purpose. <Class 0xFF>
1. Direct Transmit
To send a Pseudo APDU (PN532 and TAG Commands), and the Response Data will be returned.
Table 1.0A: Direct Transmit Command Format (Length of the PN532_TAG Command + 5 Bytes)
Command
Direct
Transmit
Lc: Number of Bytes to Send (1 Byte)
Maximum 255 bytes.
Data In: PN532_TAG Command
The data to be sent to the PN532 and Tag.
Table 1.0B: Direct Transmit Response Format (Response Length + 2 Bytes)
Response
Result
Data Out: PN532_TAG Response
PN532_TAG Response returned by the reader.
Data Out: SW1 SW2
Status Code returned by the reader.
Table 1.0C: Status Code
Results
Success 90 00 The operation is completed
Error
Checksum
Error
Class INS P1 P2 Lc Data In
0xFF 0x00 0x00 0x00 Number
of Bytes
PN532_TAG
Command
to send
Data Out
PN532_TAG
SW1 SW2
Response
SW1 SW2 Meaning
successfully.
63 00 The operation is failed.
63 27 The checksum of the Response is
wrong.
Advanced Card Systems Ltd. Page 27 of 46
PICC COMMANDS FOR GENERAL PURPOSES
1. Get Data
The “Get Data command” will return the serial number or ATS of the “connected PICC”.
Table 1.1-1a: Get UID APDU Format (5 Bytes)
Command
Get Data FF CA 00
Table 2.1-1b: Get UID Response Format (UID + 2 Bytes) if P1 = 0x00
Response
Result
UID
(LSB)
Table 2.1-1c: Get ATS of a ISO 14443 A card (ATS + 2 Bytes) if P1 = 0x01
Response
Result
Table 2.1-1d: Response Codes
Results
SW1 SW2 Meaning
Success 90 00 The operation is completed successfully.
Warning 62 82 End of UID/ATS reached before Le bytes
Error 6C XX Wrong length (wrong number Le: ‘XX’
Error 63 00 The operation is failed.
Error 6A 81 Function not supported
Examples:
// To get the serial number of the “connected PICC”
UINT8 GET_UID[5]={0xFF, 0xCA, 0x00, 0x00, 0x00};
// To get the ATS of the “connected ISO 14443 A PICC”
UINT8 GET_ATS[5]={0xFF, 0xCA, 0x01, 0x00, 0x00};
Class INS P1 P2 Le
00 00
01
(Max
Length)
Data Out
UID
SW1 SW2
(MSB)
Data Out
ATS SW1 SW2
(Le is greater than UID Length).
encodes the exact number) if Le is less
than the available UID length.
Advanced Card Systems Ltd. Page 28 of 46
PICC COMMANDS (T=CL EMULATION) FOR MIFARE 1K/4K MEMORY CARDS
2.1 Load Authentication Keys
The “Load Authentication Keys command” will load the authentication keys into the reader. The
authentication keys are used to authenticate the particular sector of the Mifare 1K/4K Memory Card.
Two kinds of authentication key locations are provided, volatile and non-volatile key locations
respectively.
Table 2.1-1a: Load Authentication Keys APDU Format (11 Bytes)
Command
Load
Authentication
Keys
Key Structure (1 Byte):
0x00 = Key is loaded into the reader volatile memory.
Other = Reserved.
Key Number (1 Byte):
0x00 ~ 0x01 = Key Location. The keys will be disappeared once the reader is disconnected from
Key (6 Bytes):
The key value loaded into the reader. E.g. {FF FF FF FF FF FF}
Table 2.1-1b: Load Authentication Keys Response Format (2 Bytes)
// Load a key {FF FF FF FF FF FF} into the key location 0x00.
APDU = {FF 82 00 00 06 FF FF FF FF FF FF}
Class INS P1 P2 Lc Data In
FF 82 Key
Structure
Key
Number
06 Key
the PC.
Data Out
SW1 SW2
SW1 SW2 Meaning
successfully.
63 00 The operation is failed.
(6 bytes)
Advanced Card Systems Ltd. `Page 29 of 46
2.2 Authentication for MIFARE 1K/4K
The “Authentication command” uses the keys stored in the reader to do authentication with the
MIFARE 1K/4K card (PICC). Two types of authentication keys are used, TYPE_A and TYPE_B
respectively.
Table 2.2-1a: Load Authentication Keys APDU Format (6 Bytes) #Obsolete
Command
Authentication
Table 2.2-1b: Load Authentication Keys APDU Format (10 Bytes)
Command
Authentication
Authenticate Data Bytes (5 Byte):
Byte1 Byte 2 Byte 3 Byte 4 Byte 5
Class INS P1 P2 P3 Data In
FF 88 00 Block
Number
Key
Type
Key Number
Class INS P1 P2 Lc Data In
FF 86 00 00 05 Authenticate Data
Bytes
Version
0x01
0x00 Block
Number
Key
Type
Key
Number
Block Number (1 Byte):
The memory block to be authenticated.
For MIFARE 1K Card, it has totally 16 sectors and each sector consists of 4 consecutive blocks.
E.g. Sector 0x00 consists of Blocks {0x00, 0x01, 0x02 and 0x03}; Sector 0x01 consists of Blocks
{0x04, 0x05, 0x06 and 0x07}; the last sector 0x0F consists of Blocks {0x3C, 0x3D, 0x3E and
0x3F}. Once the authentication is done successfully, there is no need to do the authentication again
provided that the blocks to be accessed are belonging to the same sector. Please refer to the
MIFARE 1K/4K specification for more details.
#Once the block is authenticated successfully, all the blocks belonging to the same sector are
accessible.
Key Type (1 Byte):
0x60 = Key is used as a TYPE A key for authentication.
0x61 = Key is used as a TYPE B key for authentication.
0x00 ~ 0x01 = Key Location.
Table 2.2-1b: Load Authentication Keys Response Format (2 Bytes)
// To authenticate the Block 0x04 with a {TYPE A, key number 0x00}.
// PC/SC V2.01, Obsolete
APDU = {FF 88 00 04 60 00};
<Similarly>
// To authenticate the Block 0x04 with a {TYPE A, key number 0x00}.
// PC/SC V2.07
APDU = {FF 86 00 00 05 01 00 04 60 00}
Hints:
MIFARE Ultralight does not need to do any authentication. The memory is free to access.
MIFARE Ultralight Memory Map.
Byte Number
0 1 2 3 Page
Serial Number
Serial Number
Internal / Lock
SN0 SN1 SN2 BCC0 0
SN3 SN4 SN5 SN6 1
BCC1 Internal Lock0 Lock1 2
OTP OPT0 OPT1 OTP2 OTP3 3
Data read/write
Data read/write
Data read/write
Data read/write
Data read/write
Data read/write
Data read/write
Data read/write
Data read/write
Data read/write
Data read/write
Data read/write
The “Read Binary Blocks command” is used for retrieving a multiple of “data blocks” from the
PICC. The data block/trailer block must be authenticated first before executing the “Read Binary
Blocks command”.
Table 2.3-1a: Read Binary APDU Format (5 Bytes)
Command
Read Binary
Blocks
Block Number (1 Byte):
The starting block.
Number of Bytes to Read (1 Byte):
Multiply of 16 bytes for MIFARE 1K/4K or Multiply of 4 bytes for MIFARE Ultralight
• Maximum 16 bytes for MIFARE Ultralight.
• Maximum 48 bytes for MIFARE 1K. (Multiple Blocks Mode; 3 consecutive blocks)
• Maximum 240 bytes for MIFARE 4K. (Multiple Blocks Mode; 15 consecutive blocks)
Example 1: 0x10 (16 bytes). The starting block only. (Single Block Mode)
Example 2: 0x40 (64 bytes). From the starting block to starting block+3. (Multiple Blocks Mode)
#For safety reason, the Multiple Block Mode is used for accessing Data Blocks only. The Trailer
Block is not supposed to be accessed in Multiple Blocks Mode. Please use Single Block Mode to
access the Trailer Block.
Table 2.3-1b: Read Binary Block Response Format (Multiply of 4/16 + 2 Bytes)
Response
Result
Table 2.3-1c: Read Binary Block Response Codes
Results
Success 90 00 The operation is completed
Error
Examples:
// Read 16 bytes from the binary block 0x04 (MIFARE 1K or 4K)
APDU = {FF B0 00 04 10}
// Read 240 bytes starting from the binary block 0x80 (MIFARE 4K)
// Block 0x80 to Block 0x8E (15 blocks)
APDU = {FF B0 00 80 F0}
Class INS P1 P2 Le
FF B0 00 Block
Number
Number
of Bytes
to Read
Data Out
Data (Multiply of 4/16 Bytes)
SW1 SW2
SW1 SW2 Meaning
successfully.
63 00 The operation is failed.
Advanced Card Systems Ltd. Page 33 of 46
2.4 Update Binary Blocks
The “Update Binary Blocks command” is used for writing a multiple of “data blocks” into the
PICC. The data block/trailer block must be authenticated first before executing the “Update Binary
Blocks command”.
Table 2.3-1a: Update Binary APDU Format (Multiple of 16 + 5 Bytes)
Command
Update Binary
Blocks
Block Number (1 Byte):
The starting block to be updated.
Number of Bytes to Update (1 Byte):
• Multiply of 16 bytes for MIFARE 1K/4K or 4 bytes for MIFARE Ultralight.
• Maximum 48 bytes for MIFARE 1K. (Multiple Blocks Mode; 3 consecutive blocks)
• Maximum 240 bytes for MIFARE 4K. (Multiple Blocks Mode; 15 consecutive blocks)
Example 1: 0x10 (16 bytes). The starting block only. (Single Block Mode)
Example 2: 0x30 (48 bytes). From the starting block to starting block+2. (Multiple Blocks Mode)
#For safety reason, the Multiple Block Mode is used for accessing Data Blocks only. The Trailer
Block is not supposed to be accessed in Multiple Blocks Mode. Please use Single Block Mode to
access the Trailer Block.
Block Data (Multiply of 16 + 2 Bytes, or 6 bytes):
The data to be written into the binary block/blocks.
// Update the binary block 0x04 of MIFARE 1K/4K with Data {00 01 .. 0F}
APDU = {FF D6 00 04 10 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F}
// Update the binary block 0x04 of MIFARE Ultralight with Data {00 01 02 03}
APDU = {FF D6 00 04 04 00 01 02 03}
Class INS P1 P2 Lc Data In
FF D6 00 Block
Number
Number
of Bytes
to
Block Data
(Multiple of 16
Bytes)
Update
SW1 SW2 Meaning
successfully.
63 00 The operation is failed.
Advanced Card Systems Ltd. `Page 34 of 46
2.5 Value Block Related Commands
The data block can be used as value block for implementing value-based applications.
2.5.1 Value Block Operation
The “Value Block Operation command” is used for manipulating value-based transactions. E.g.
Increment a value of the value block etc.
Table 2.5.1-1a: Value Block Operation APDU Format (10 Bytes)
Command
Value Block
Operation
Block Number (1 Byte):
The value block to be manipulated.
VB_OP (1 Byte):
0x00 = Store the VB_Value into the block. The block will then be converted to a value block.
0x01 = Increment the value of the value block by the VB_Value. This command is only valid for
value block.
0x02 = Decrement the value of the value block by the VB_Value. This command is only valid for
value block.
VB_Value (4 Bytes):
The value used for value manipulation. The value is a signed long integer (4 bytes).
E.g. 1: Decimal –4 = {0xFF, 0xFF, 0xFF, 0xFC}
MSB LSB
FF FF FF FC
E.g. 2: Decimal 1 = {0x00, 0x00, 0x00, 0x01}
MSB LSB
00 00 00 01
Table 2.5.1-1b: Value Block Operation Response Format (2 Bytes)
Response
Result SW1 SW2
Table 2.5.1-1c: Value Block Operation Response Codes
Results
Success 90 00 The operation is completed
Error
Class INS P1 P2 Lc Data In
FF D7 00 Block
Number
05 VB_OP
VB_Value
(4 Bytes)
{MSB .. LSB}
VB_Value
VB_Value
Data Out
SW1 SW2 Meaning
successfully.
63 00 The operation is failed.
Advanced Card Systems Ltd. Page 35 of 46
2.5.2 Read Value Block
The “Read Value Block command” is used for retrieving the value from the value block. This
command is only valid for value block.
Table 2.5.2-1a: Read Value Block APDU Format (5 Bytes)
Command
Read Value
Block
Block Number (1 Byte):
The value block to be accessed.
Table 2.5.2-1b: Read Value Block Response Format (4 + 2 Bytes)
Response
Result
Value (4 Bytes):
The value returned from the card. The value is a signed long integer (4 bytes).
E.g. 1: Decimal –4 = {0xFF, 0xFF, 0xFF, 0xFC}
MSB LSB
FF FF FF FC
E.g. 2: Decimal 1 = {0x00, 0x00, 0x00, 0x01}
MSB LSB
00 00 00 01
Table 2.5.3-1c: Read Value Block Response Codes
Results
Success 90 00 The operation is completed
Error
Class INS P1 P2 Le
FF B1 00 Block
00
Number
Data Out
Value
SW1 SW2
{MSB .. LSB}
Value
Value
SW1 SW2 Meaning
successfully.
63 00 The operation is failed.
Advanced Card Systems Ltd. `Page 36 of 46
2.5.3 Restore Value Block
The “Restore Value Block command” is used to copy a value from a value block to another value
block.
Table 2.5.3-1a: Restore Value Block APDU Format (7 Bytes)
Command
Value Block
Operation
Source Block Number (1 Byte): The value of the source value block will be copied to the target
Target Block Number (1 Byte): The value block to be restored. The source and target value
Table 2.5.3-1b: Restore Value Block Response Format (2 Bytes)
Response
Result
Table 2.5.3-1c: Restore Value Block Response Codes
Results
Success 90 00 The operation is completed
Error
Class INS P1 P2 Lc Data In
FF D7 00 Source
Block
Number
02 03 Target
Block
Number
value block.
blocks must be in the same sector.
Data Out
SW1 SW2
SW1 SW2 Meaning
successfully.
63 00 The operation is failed.
Advanced Card Systems Ltd. Page 37 of 46
Examples:
// Store a value “1” into block 0x05
APDU = {FF D7 00 05 05 00 00 00 00 01}
// Read the value block 0x05
APDU = {FF B1 00 05 00}
// Copy the value from value block 0x05 to value block 0x06
APDU = {FF D7 00 05 02 0306}
// Increment the value block 0x05 by “5”
APDU = {FF D7 00 05 05 01 00 00 00 05}
BASIC PROGRAM FLOW FOR CONTACTLESS APPLICATIONS
Step 0. Start the application. The reader will do the PICC Polling and scan for tags continuously.
Once the tag is found and detected, the corresponding ATR will be sent to the PC.
Step 1. Connect the “ACR1222U PICC Interface” with T=1 protocol.
Step 2. Access the PICC by exchanging APDUs.
Step 2. Access the PICC by exchanging APDUs.
..
Step N. Disconnect the “ACR1222U PICC Interface”. Shut down the application.
Remarks:
1) The antenna can be switched off in order to save the power.
• Turn off the antenna power: FF 00 00 00 04 D4 32 01 00
• Turn on the antenna power: FF 00 00 00 04 D4 32 01 01
Advanced Card Systems Ltd. `Page 38 of 46
1. How to access PCSC Compliant Tags (ISO14443-4)?
Basically, all ISO 14443-4 complaint cards (PICCs) would understand the ISO 7816-4 APDUs.
The ACR1222U Reader just has to communicate with the ISO 14443-4 complaint cards through
exchanging ISO 7816-4 APDUs and Responses. ACR1222U will handle the ISO 14443 Parts 1-4
Protocols internally.
MIFARE 1K, 4K, MINI and Ultralight tags are supported through the T=CL emulation. Just simply
treat the MIFARE tags as standard ISO14443-4 tags. For more information, please refer to topic
“PICC Commands for MIFARE Classic Memory Tags”
Table 3.1-1a: ISO 7816-4 APDU Format
Command Class INS P1 P2 Lc Data In
ISO 7816 Part
4 Command
Length
of the
Data In
Table 3.1-1b: ISO 7816-4 Response Format (Data + 2 Bytes)
Response
Data Out
Result
Response Data SW1 SW2
Table 3.1-1c: Common ISO 7816-4 Response Codes
Results
SW1 SW2 Meaning
Success 90 00 The operation is completed
successfully.
Error
63 00 The operation is failed.
Expected
Le
length of
the
Response
Data
Advanced Card Systems Ltd. Page 39 of 46
Typical sequence may be:
- Present the Tag and Connect the PICC Interface
- Read / Update the memory of the tag
Step 1) Connect the Tag
The ATR of the tag is 3B 8C 80 01 50 00 05 70 3B 00 00 00 00 33 81 81 20
In which,
The ATQB = 50 00 05 70 3B 00 00 00 00 33 81 81. It is an ISO14443-4 Type B tag.
Step 2) Send an APDU, Get Challenge.
<< 00 84 00 00 08
>> 1A F7 F3 1B CD 2B A9 58 [90 00]
Hint:
For ISO14443-4 Type A tags, the ATS can be obtained by using the APDU “FF CA 01 00 00”
Advanced Card Systems Ltd. Page 40 of 46
For Example: ISO7816-4 APDU
// To read 8 bytes from an ISO 14443-4 Type B PICC (ST19XR08E)
APDU ={80 B2 80 00 08}
Class = 0x80
INS = 0xB2
P1 = 0x80
P2 = 0x00
Lc = None
Data In = None
Le = 0x08
Answer: 00 01 02 03 04 05 06 07 [$9000]
Advanced Card Systems Ltd. Page 41 of 46
2. How to access DESFIRE Tags (ISO14443-4)?
The DESFIRE supports ISO7816-4 APDU Wrapping and Native modes. Once the DESFire Tag is
activated, the first APDU sent to the DESFire Tag will determine the “Command Mode”. If the first
APDU is “Native Mode”, the rest of the APDUs must be in “Native Mode” format. Similarly, If the
first APDU is “ISO7816-4 APDU Wrapping Mode”, the rest of the APDUs must be in “ISO7816-4
APDU Wrapping Mode” format.
Example 1: DESFIRE ISO7816-4 APDU Wrapping.
// To read 8 bytes random number from an ISO 14443-4 Type A PICC (DESFIRE)
APDU = {90 0A 00 00 01 00 00}
Class = 0x90; INS = 0x0A (DESFire Instruction); P1 = 0x00; P2 = 0x00
Lc = 0x01; Data In = 0x00; Le = 0x00 (Le = 0x00 for maximum length)
Answer: 7B 18 92 9D 9A 25 05 21 [$91AF]
# Status Code{91 AF} is defined in DESFIRE specification. Please refer to the DESFIRE
specification for more details.
Example 2: DESFIRE Frame Level Chaining (ISO 7816 wrapping mode)
// In this example, the application has to do the “Frame Level Chaining”.
// To get the version of the DESFIRE card.
Step 1: Send an APDU {90 60 00 00 00} to get the first frame. INS=0x60
Answer: 04 01 01 00 02 18 05 91 AF [$91AF]
Step 2: Send an APDU {90 AF 00 00 00} to get the second frame. INS=0xAF
Answer: 04 01 01 00 06 18 05 91 AF [$91AF]
Step 3: Send an APDU {90 AF 00 00 00} to get the last frame. INS=0xAF
Answer: 04 52 5A 19 B2 1B 80 8E 36 54 4D 40 26 04 91 00 [$9100]
Advanced Card Systems Ltd. Page 42 of 46
Example 3: DESFIRE Native Command.
// We can send Native DESFire Commands to the reader without ISO7816 wrapping if we find that
the Native DESFire Commands are more easier to handle.
// To read 8 bytes random number from an ISO 14443-4 Type A PICC (DESFIRE)
APDU = {0A 00}
Answer: AF 25 9C 65 0C 87 65 1D D7[$1DD7]
In which, the first byte “AF” is the status code returned by the DESFire Card.
The Data inside the blanket [$1DD7] can simply be ignored by the application.
Example 4: DESFIRE Frame Level Chaining (Native Mode)
// In this example, the application has to do the “Frame Level Chaining”.
// To get the version of the DESFIRE card.
Step 1: Send an APDU {60} to get the first frame. INS=0x60
Answer: AF 04 01 01 00 02 18 05[$1805]
Step 2: Send an APDU {AF} to get the second frame. INS=0xAF
Answer: AF 04 01 01 00 06 18 05[$1805]
Step 3: Send an APDU {AF} to get the last frame. INS=0xAF
Answer: 00 04 52 5A 19 B2 1B 80 8E 36 54 4D 40 26 04[$2604]
Hints:
In DESFIRE Native Mode, the status code [90 00] will not be added to the response if the response
length is greater than 1. If the response length is less than 2, the status code [90 00] will be added in
order to meet the requirement of PCSC. The minimum response length is 2.
3. How to access FeliCa Tags (ISO18092)?
Typical sequence may be:
- Present the FeliCa Tag and Connect the PICC Interface
Step 2) Read the memory block without usingPseudo APDU.
<< 10 06 [8-byte NFC ID] 01 09 01 01 80 00
>> 1D 07 [8-byte NFC ID] 00 00 01 00 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55