Smartcard Library Overview

Smart Card Library

Smart Card Library
Smartcard Library Overview

Two communication protocols that are generally used for contact type smart card communications are:

  • T = 0 (asynchronous half duplex character transmission)
  • T = 1 (asynchronous half duplex block transmission)

The data transfers between the card and the terminal(smart card reader) happens on the single wire I/O line. 

Following the initial reset of the card after insertion, the card responds with a series of characters called the Answer to Reset, or ATR. This series of characters establishes the initial communication details, including the specific protocol, bit timing, and data transfer details for all subsequent communications. While subsequent data transfers can change certain communications parameters, the ATR establishes initial communications conditions. 

The Clock Signal for Baud rate generation is provided to the card by the reader (terminal). The Smartcard default baudrate divider is 372, which produce 9600 bps when a clock signal of 3.57MHz is supplied to the card. Most Smartcards allow higher clock rates, so a simple 4MHz clock can be easily used. Using a 4MHz clock, the default baudrate comes out to be 10752 bps. The PICs UART is appropriately configured by the library, so the communication can be setup using the higher baudrate settings. 

The Smartcard 7816-3 communications requires a 0.5 stop bit. This is important for the Receiver, as it must pull the I/O line low before the middle of the stop bit (10.5 bit time from start edge) in order to indicate error condition to the Transmitter. The receiver pulls the line low for 1 to 2 bit time (etu). The transmitter checks the I/O line at the end of stop bit, or 11 etu. If the transmitter detects the line low, it retransmit the previous data byte after at least 2 etu. 

The uart peripheral in PIC micros sets Rx Ready and Transmitter Empty flags to true at 0.5 stop bit, which allows the implementation of the 7816-3 error detection and retransmission protocol possible. 

 

Topics
Name 
Description 
The Smartcard Library has a modular design with separate files for the high level library code and the low level driver for UART for implementing the ISO7816-3/4 protocol.
 
The current release of smart card library supports PIC18, PIC24F, dsPIC33F, PIC24H & PIC32MX microcontrollers.The smart card library provides the API necessary to communicate with the ISO7816-3/4 compliant Smartcard. The sequence of the API calls is as given below. SClib.h contains all the API's that are required by the main application to communicate with the smart card. The current release of smart card library supports both T=0 and T=1 protocol.
...
//Initialize smart card stack
SC_Initialize();
...
// Wait untill the card is inserted in the slot
while( !SC_CardPresent() )
...
//After detecting the card, turn on... more 
Microchip Smart Card Library 1.02.8 - [July 18, 2012]
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.