Electronic – Smart Card (SIM) clocking requirements

iso7816simsmart-cardtexas instrumentstimer

I'm trying to implement a SIM card interface using TI TM4C123XL. I have a question about a clock. TI MCU seems to provide possibility to interface smart cards but don't let me multiply clock without multiplying baud rate. So it seems to me I will have to generate the clock using timer myself. So, how precise should a clock be? Should clock be synchronised with data? If so, how? What is its purpose?

Best Answer

First, everything is specified in ISO7816-3. You should really read it (I won't provide any links because the standard is not free, but you can still easily find it on the web). Now, regarding your specific questions:

Yes, you need to generate the clock that will be applied to the CLK pin. This clock does not need to be accurate. There is, however, a maximum and minimum value specified in the standard (1MHz min and 5MHz max - see chapter 5.2.3).

Yes, the clock needs to be synchronized with the data. At startup, there should be a ratio of 372 between the CLK frequency and the baud rate. Then, you can negociate higher speeds using the PPS protocol (this allows you to change this ratio, and also eventually use clock frequencies above 5MHz).

The original purpose of this clock was, basically, to be used as the main clock for the MCU. Smart cards were invented at a time when it was impractical to embed an internal oscillator within such a small MCU, so there had to be an external clock source. Now, most smart cards chips embed their own oscillator, because they can work at much higher speeds than the provided 1~5MHz clock, but the external clock is still used for synchronization of the communication (just because the standard requires it).