Atmel AT91 Application Note
Hide thumbs Also See for AT91:

Advertisement

Quick Links

Software ISO 7816 I/O Line Implementation
Features
• ISO 7816-3 compliant (direct convention)
• Byte reception and transmission with parity check
• Retransmission on error detection
• Automatic reception at the end of transmission
• Dynamically programmable baud rate (PTS)
• ARM Procedure Call Standard (APCS) compliant
Introduction
ISO 7816-3 is the standard for electronic signals and transmission protocols for IC
cards with contacts. It defines the characteristics of the signals used to communicate
with a Smart Card including the I/O line which allows messages to be exchanged. The
AT91M40400 does not have dedicated hardware to manage the ISO 7816 I/O line,
but because of the high processing speed and flexible Timer Counter (TC), an effec-
tive software implementation can easily be performed.
AT91
®
ARM Thumb
Microcontrollers
Application Note
Rev. 1154A–08/98
1

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the AT91 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Atmel AT91

  • Page 1 Software ISO 7816 I/O Line Implementation AT91 Features • ISO 7816-3 compliant (direct convention) ® ARM Thumb • Byte reception and transmission with parity check • Retransmission on error detection Microcontrollers • Automatic reception at the end of transmission • Dynamically programmable baud rate (PTS) •...
  • Page 2: Theory Of Operation

    • one start bit at low level • 8 data bits of information (from Least Significant Bit to Most Significant Bit) • one parity bit • two (if no error) or three (if error) stop bits at high level AT91 ARM Thumb...
  • Page 3 AT91 ARM Thumb The ISO 7816-3 specification implements two different conventions for data transfer: direct or reverse convention. For more convenience, this application note refers to the direct convention, which is to say: • not inverted bits (logical “1” = HIGH state) •...
  • Page 4: Source Files

    For each peripheral used (Timer Counter, Interrupt Controller, etc.) a structure is defined to provide easy access to the peripheral registers. Constants are also defined to provide easy access to the register fields. These types and constants are defined in tc.h , aic.h , pio.h . AT91 ARM Thumb...
  • Page 5: Global Variables

    AT91 ARM Thumb Global Variables Global variables relative to a timer used as the ISO line are grouped into a structure (ISO_LINE_VAR type defined in iso_line.h ). This structure groups the timer characteristics (base address, PIO pins, etc), buffers pointers, working variables, and inter- rupt handler addresses (AIC handler and C handler).
  • Page 6 The IsoLineTxStatus function allows the user to obtain the current transmission status (in progress, ended, or try over- flow). Begin | If too much tries return TX_OVERFLOW | If all bytes transmitted return TX_ENDED | Else return TX_IN_PROGRESS AT91 ARM Thumb...
  • Page 7: Interrupt Management

    These operations are performed using the IRQ_ENTRY and IRQ_EXIT macros provided by the AT91 library. Between these macros, the handler loads the variable structure corre- sponding to the timer which caused the interrupt (see Global variables section) and calls the IsoLineHandlerInt C handler with this structure as parameter.
  • Page 8 It also initializes the bit counter and the calculated parity value. The interrupt handler is changed to IsoRxReceivedBit. Begin | Enable trigger on RC Compare event and disable external trigger | bit counter <- 0 | Change IT handler to ‘IsoRxReceiveBits’ AT91 ARM Thumb...
  • Page 9 AT91 ARM Thumb The IsoRxReceivedBit function gets the bit value on the I/O line from the PIO_PDSR (Pin Data Status Register) to get the data or parity bit value. On each bit, the parity calculation is updated. When the bit counter reaches 9, the calculated parity must be 0.
  • Page 10 Start to send Read not empty empty Reception mode start bit acknowledgement first handler StartByte ReadAcknow ReceiveByte acknowledge number of number of tries not tries Wait start of End of overflowed overflowed transmission Third stop bit WaitByte ThirdStop AT91 ARM Thumb...
  • Page 11 AT91 ARM Thumb Figure 8. Transmission without Parity Error guard time start byte i start byte i+1 (2 stop bits) C(1) C(2) C(3) C(4) C(5) C(6) C(7) C(8) C(9) F then B C(1) Figure 9. Transmission with Parity Error error...
  • Page 12 IsoTxStartByte. If the limiting number of attempts is reached, the channel is pre- pared for reception by calling the function IsoRxReceiveByte. Begin | Increase try number | If try number reached | | start reception (IsoRxReceiveByte) | Else | | Start retransmission (IsoTxSendByte) | Endif AT91 ARM Thumb...
  • Page 13: Tips And Warnings

    AT91 ARM Thumb Tips and Warnings Delay Before Transmission In this application note, a delay has been inserted before sending the first byte. This delay can be removed if the applica- tion (pear equipment) does not need it or it can be modified. It is calculated in the function IsoLineBaudRate, and saved in the field ‘...

Table of Contents