Selection Recommendations | Essential Guide for Smart Card Development! Comprehensive Guide to Choosing PIC® MCUs for Finance, IoT, and Access Control Systems

Understanding with PIC® MCU

Contact Smart Card

SMART CARD

A smart card is a pocket-sized card embedded with an integrated circuit that can respond to requests from external devices,capable of both data storage and processing. Compared to magnetic stripe cards, they are more reliable, secure, have larger storage capacity, more functions, and a longer lifespan. Currently, smart cards are widely used in information security, physical access control, banking, telecommunications and transportation, retail membership, healthcare, government projects, and campus identity verification.

According to the connection method with the card reader, smart cards are divided into two categories:

  • Contact: Data exchange with the reader through direct physical contact.

  • Contactless: Remote communication via radio frequency interface.

In practical applications, contact smart cards are usually interacted with by personal computer (PC) applications through a reader interface device (see the image below).

Selection Recommendations | Essential Guide for Smart Card Development! Comprehensive Guide to Choosing PIC® MCUs for Finance, IoT, and Access Control SystemsContact Smart Card and ISO 7816Selection Recommendations | Essential Guide for Smart Card Development! Comprehensive Guide to Choosing PIC® MCUs for Finance, IoT, and Access Control Systems

ISO 7816 is a set of international standards that define the interface requirements between contact smart cards and card reading devices, divided into several parts:

  • ISO 7816-1: Specifies the physical characteristics of the card, such as size, durability, etc.

  • ISO 7816-2: Specifies the size and position of the chip contacts

  • ISO 7816-3: Specifies the electronic signal characteristics and transmission protocols (including T=0, T=1)

  • ISO 7816-4: Specifies the organization of data exchange, security mechanisms, and command formats

Selection Recommendations | Essential Guide for Smart Card Development! Comprehensive Guide to Choosing PIC® MCUs for Finance, IoT, and Access Control Systems

In the standard, ISO 7816-2 defines 8 contacts (see the image below), but in actual communication, usually only 6 of them are used, namely: Vcc, GND, CLK, RST, I/O, and VPP (most modern cards do not use Vpp).

Selection Recommendations | Essential Guide for Smart Card Development! Comprehensive Guide to Choosing PIC® MCUs for Finance, IoT, and Access Control SystemsSmart Card Communication ProcessSelection Recommendations | Essential Guide for Smart Card Development! Comprehensive Guide to Choosing PIC® MCUs for Finance, IoT, and Access Control Systems

According to ISO 7816, the communication between contact smart cards and the main controller (such as PIC® MCU) is usually divided into the following stages:

1. Card Insertion Detection: The main controller detects the card inserted into the card slot

2. Cold Reset:The MCU provides the operating voltage (Vcc), a stable clock signal (CLK), and performs a standard timing reset process through the reset pin (RST) (RST low level ≥ 400 clock cycles then pull high).

3. ATR (Answer to Reset):The card sends ATR information through I/O after startup, including:

  • Logical level rules (positive logic/negative logic)

  • Data bit transmission order (LSb or MSb first)

  • Communication rate parameters (F, D, ETU)

  • Supported protocol types (T=0 or T=1)

  • Historical information (manufacturer, model, etc., optional)

  • Checksum byte (TCK)

4. PPS (Optional Parameter Negotiation):If the card supports it, the main controller can adjust communication rate and other parameters through PPS, effective after the card responds with confirmation.

5. Command Execution: Data exchange according to protocol type:

T=0 Protocol (Byte Transmission)

  • The MCU sends C-APDU (command header and optional data)

  • The card returns process bytes, followed by data exchange

  • Returns status word SW1/SW2 at the end

T=1 Protocol (Block Transmission)

  • Data is encapsulated as I-Block (information), R-Block (acknowledgment/negative acknowledgment), or S-Block (control)

  • Supports CRC/LRC error checking

  • Negotiable information field length (IFS) and extended processing time (BWT)

6. Card Removal Check:The main controller detects the card removal.

7. Secure Deactivation:The main controller shuts down power and signal output, ending this communication session.

Two Mainstream Protocols: T=0 vs T=1T=0: Byte-based, half

T=0: Byte-based, half-duplex

  • Transmits and receives by byte, with the minimum processing unit being 1 byte.

  • The main controller sendsC-APDU (command), the card responds withR-APDU (data + status code).

  • The response status codeSW1/SW2indicates the execution result (e.g., 0x9000 for success).

  • Suitable for scenarios with simple commands and small data volumes (e.g., identity authentication, simple transactions).

T=1: Block-based, half-duplex

  • Transmits and receives by data block, divided into I-Block (data), R-Block (acknowledgment), S-Block (control).

  • Supports larger data volume transmission, with CRC or LRC error checking.

  • Commonly used in scenarios requiring bulk data exchange (e.g., file reading, OTA updates).

Engineering Selection Recommendations:

  • Modules and terminal MCUs should support both T=0 and T=1 protocols for higher compatibility.

  • When purchasing chips, confirm whether the protocol stack is mature to avoid subsequent software redevelopment costs.

Key Timing ParametersIn smart card communication, it is essential not only to “speak” correctly but also to “speak” accurately. The ISO 7816 standard has strict timing requirements, and the following timing parameters are key to ensuring stability and compatibility:

✅CGT (Character Guard Time)

The minimum delay between two consecutive characters. Fixed at 12 ETU during the ATR phase, then calculated based on parameters returned by the card.

✅WT (Wait Time)

The maximum time for the smart card to respond. If there is no response beyond this time, it should be judged as a timeout or card failure.

✅BGT (Block Guard Time)

Used only in T=1 protocol, defining the minimum delay between reverse transmissions, fixed at 22 ETU.

✅CWT (Character Wait Time)

The maximum delay between consecutive characters within a block in T=1 protocol.

✅BWT (Block Wait Time)

The maximum delay between blocks in T=1 protocol, usually calculated based on parameters returned by the card.

These parameters are usually determined during the ATR or PPS phase, and improper handling may lead to communication timeouts or frequent retransmissions.

Hardware Implementation Based on PIC18F14K50

In contact smart card applications, the MICROCHIP PIC18F14K50 MCU plays a core control role, responsible for signal control and protocol processing. Typical hardware design includes:

  • Power Control: Control the card’s Vcc power on/off through GPIO

  • Reset Control: Output reset signal through GPIO, operating according to ISO 7816 timing requirements

  • Clock Output: Use the MCU’s PWM module to provide the reference clock required by the card (e.g., 3.579 MHz)

  • Data Communication: Connect UART_RX and UART_TX to the card’s I/O for half-duplex communication

  • Card Detection: Use GPIO to read the card slot detection signal to determine if a card is inserted

Minimum hardware resource requirements:

  • 1 PWM channel (or dedicated clock output)

  • 1 timer

  • 1 UART interface

  • 6 GPIOs

For cards requiring higher power current, a power amplifier can be added between the MCU and the card slot Vcc to ensure stable power supply.

Application Scenarios and AdvantagesContact smart cards based on the PIC18F14K50 chip have the following advantages:

Contact smart cards based on the PIC18F14K50 chip have the following advantages:

  • High Integration: A single MCU can complete power supply, reset, clock, communication, and card detection

  • Protocol Compatibility: Supports ISO 7816-3/4, T=0 and T=1 protocols

  • Low-Cost Implementation: Reduces the need for peripheral chips, lowering BOM costs

  • Strong Reliability: Strictly controls timing according to standards, reducing communication errors

Selection Recommendations | Essential Guide for Smart Card Development! Comprehensive Guide to Choosing PIC® MCUs for Finance, IoT, and Access Control Systems

Typical applications include:

✅ Financial/Bank Terminals (POS, Self-Service Kiosks)

Execute application selection (SELECT), card identity authentication, transaction parameter reading, transaction data writing, and status return (SW1/SW2). The PIC18F14K50 has built-in full-speed USB and hardware UART, which can stably drive the smart card interface, ensuring accurate transmission of transaction data under T=0 protocol, reducing transaction failures and timeouts, and ensuring a smooth card swiping experience.

✅ Public Transport/Ticketing and Recharge

Execute top-up amounts, balance inquiries, transaction record reading and appending. The PIC18F14K50 supports T=0/T=1 protocol switching, bulk data (such as transaction logs) can be efficiently transmitted via I-Block/R-Block, and can adjust rates with PPS, meeting the demand for fast card swiping and bulk data synchronization during peak periods.

✅ Access Control/Visitor Management

Read card numbers or unique identifiers, verify passwords/keys, check permissions, and output door opening signals. With high-speed I/O and precise clock, the PIC18F14K50 can complete card reading and verification in milliseconds; low-power mode is suitable for long standby times, and the built-in EEPROM can directly store authorized lists and encryption keys, reducing reliance on external storage chips.

✅ Medical Cards/Social Security Cards

Execute file selection, read personal information and medical records, write visit or reimbursement marks. The PIC18F14K50 can stably parse complex APDU file structures and long data blocks, and with external encryption modules can achieve dual authentication, adapting to different regional government or social security card standards.

✅ Campus Cards/Corporate Identity Recognition and Consumption

Execute identity authentication, consumption deduction, subsidy issuance, and whitelist/blacklist updates. The PIC18F14K50 can simultaneously complete identity verification and deduction processing within a single MCU, supporting PPS negotiated rates, maintaining smooth performance even in high-concurrency scenarios; built-in peripherals can directly drive gates, displays, buzzers, and other hardware.

✅ Production Testing/Laboratory Equipment (including SIM card/smart card compatibility testing)Execute bulk scripted APDU commands, boundary condition testing, lifespan and compatibility verification. The PIC18F14K50 fully supports ATR/PPS protocol stack, with exception recovery and retransmission mechanisms, capable of testing various card types and voltage levels (Class A/B/C), helping manufacturers reduce testing system development and maintenance costs.

Selection Recommendations | Essential Guide for Smart Card Development! Comprehensive Guide to Choosing PIC® MCUs for Finance, IoT, and Access Control SystemsConclusion

Contact smart card technology, with its security and international standardization advantages, has become a core authentication method in various fields such as financial payments, identity verification, and access control. In specific implementations,PIC18F14K50 MCU features low cost, high stability, and comprehensive protocol support, efficiently realizing smart card read/write functions in portable terminals, embedded systems, and various scenarios. As a technology-oriented supplier with long-term experience in semiconductor distribution, we can provide stable stock supply of models likePIC18F14K50 and timely delivery assurance, and offer original factory technical support, assisting your smart card projects to maintain stable progress during development and mass production.

ENDSelection Recommendations | Essential Guide for Smart Card Development! Comprehensive Guide to Choosing PIC® MCUs for Finance, IoT, and Access Control Systems

Contact Email[email protected]

Address丨20F-20G, Block A, Huaqiang Plaza, Futian District, Shenzhen

Leave a Comment