【转】Ultra simple ISO-7816 Interface
原文出自 http://hilbert-space.de/?p=135
While laying out a PCB for my SWP reader project I realized that I haven’t ever tested the ISO-7816 (aka contact) interface yet. I probably forgot that because it’s not all that difficult and not that interesting, but I’d rather see it working before I order PCBs.
So I spend an hour or two in the internet looking for inspiration how other people did it. There are lots of specialized chips for this purpose out there, but sourcing is always a problem and since it’s “just” a simple serial interface I was more interested in a simple hack that will work.
Turns out there are a lot of simple SIM/Smart-card readers out there that just do this, and they pretty much all look like this:

Here Q1 is running as a open collector driver with R1 as a pull-up resistor. This transistor will invert the signal, that’s why there is an additional inverter A1 in front of the base. R2 and C1 are the usual base-resistor and speed-up capacitor.
You’ll find variations of this basic circuit all over the net. Sometimes they omit the speed-up capacitor, sometimes you find buffers in the RX-UART path, but that’s it basically.
I heated up my soldering iron and gave this circuit a test drive, and lo and behold: It works as expected (aka good enough in practice).
So problem solved, move on.
Not so. In the
middle of the night it came to me, that almost the entire circuit is
unnecessary. What does it really do? On the Q1 collector we see a
replica of the TX-UART signal. The SIM card IO pin (which is just an
open collector IO-pin) is able to pull the signal down at will without
causing a short to TX-UART.
RX-UART picks up
this signal and echoes back either what comes from TX-UART or from IO.
Neither pin is pulling up the signal, that’s what R1 is doing.
So how about this:

It’s working just the same, just faster and with less parts.
In case that
TX-UART is transmitting, and IO is listening the singal will just pass
R1. If TX-UART stops transmitting the UART will go into idle-state
(logic high). This effectively ties R1 to VCC and we have exactly the
same behaviour as with the more “complex” circuit.
If the SIM transmit
something SIM-IO just pulls the line down to ground. A bit of current
will flow out of TX-UART, but that’s fine. Compared to drive a LED from a
GPIO pin that’s nothing.
If you feel inspired to try this out, here is a short how-to:
- Configure the UART on the micro-controller side for 9600 baud, 8 data bits, two stop-bits and even parity.
- Power the SIM VCC pin, have reset low.
- Apply a clock signal 372 times the UART baud-rate: 3.57 Mhz.
- Wait a little for the SIM/SmartCard to stabilize.
- Raise the reset line to taking the SIM-card out of reset.
And then watch the
Answer to Rest (ATR) signature arriving at your micro-controller UART-RX
pin. You’re now ready to implement the ISO7816-3 T=0 or T=1 protocol
and do some real data-exchange. With practically any micro-controller
and just a simple resistor.
Oh, by the way.
You’re allowed to let the IO pin of the SIM to pull down up to 500µA, so
if you get problems with stray capacitance just lower R1. Minimum
values are:
- 3.6k for 1.8V supply
- 6.6k for 3.3V supply
- 10k for 5V supply.

【转】Ultra simple ISO-7816 Interface的更多相关文章
- a simple and universal interface between web servers and web applications or frameworks: the Python Web Server Gateway Interface (WSGI).
WSGI is the Web Server Gateway Interface. It is a specification that describes how a web server comm ...
- STM32F401
The STM32F401 line is the entry level to the STM32 F4 series. It is designed for medical, industrial ...
- ISO 7810 协议小结
ISO 7816规定了Smart Card的传输协议分为 T=0 异步半双工字符传输协议 T=1 异步半双工块传输协议 T=0命令介绍 命令总是由接口设备启动,他以一个5字节的报头通知卡要做什么,然后 ...
- Common Gateway Interface Python CGI编程
https://en.wikipedia.org/wiki/Gateway_(telecommunications) In telecommunications, the term gateway r ...
- Awesome C/C++
Awesome C/C++ A curated list of awesome C/C++ frameworks, libraries, resources, and shiny things. In ...
- awesome cpp
https://github.com/fffaraz/awesome-cpp Awesome C/C++ A curated list of awesome C/C++ frameworks, lib ...
- Styles and Themens(4)android自定义主题时可使用的属性
A list of the standard attributes that you can use in themes can be found at R.styleable.Theme. Cons ...
- [转]awsome c++
原文链接 Awesome C++ A curated list of awesome C++ (or C) frameworks, libraries, resources, and shiny th ...
- Pyhton开源框架(加强版)
info:Djangourl:https://www.oschina.net/p/djangodetail: Django 是 Python 编程语言驱动的一个开源模型-视图-控制器(MVC)风格的 ...
随机推荐
- 【socket编程】什么是socket编程
Socket简介 Socket是进程通讯的一种方式,即调用这个网络库的一些API函数实现分布在不同主机的相关进程之间的数据交换. 几个定义: (1)IP地址:即依照TCP/IP协议分配给本地主机的网络 ...
- 多线程安全问题之Lock显示锁
package com.hls.juc; import java.util.concurrent.locks.Lock;import java.util.concurrent.locks.Reentr ...
- nyoj 单调递增子序列(二)
单调递增子序列(二) 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 给定一整型数列{a1,a2...,an}(0<n<=100000),找出单调递增最长 ...
- django model 插入数据方法
需要插入的数据表结构如下: class UserInfo(models.Model): user_id =models.AutoField(primary_key=True) user_name=mo ...
- 深入理解ASP.NET MVC(目录)
学ASP.NET MVC2有一段时间了,也针对性的做了个练习.感觉这个框架还是不错的,所以决定要深入系统的学习一下.看到这样一本书: 作者博客:http://blog.stevensanderson. ...
- jQuery与DOM对象的转换
一.jQuery与DOM对象的转换. 1.jQuery对象转换为DOM对象:$cr[0] 或 $cr.get(0) $cr为jQuery对象 2.DOM对象转换为jQuery对象:$(cr) cr为D ...
- Microsoft Dynamics CRM 2011 新建实体 需要注意的细节
新建一个实体,需要红色框内的是否勾选的意义,可以进一步加深对CRM的理解.如图: 下面对部分的进行了自我的理解,不对的地方,还请大家指出来.互相学习. 1.CRM2011中,在活动方面加强的新特性包括 ...
- PHP解析xml文件时报错:I/O warning : failed to load external entity
在代码顶部增加 libxml_disable_entity_loader(false); libxml_disable_entity_loader()作用是设置是否禁止从外部加载XML实体,设为tru ...
- netty初步
netty是java的高性能socket框架,linux下基epoll,这里不对他多牛逼作分析,网上资料很多,这里针对一般socket的业务作个例子 几个基本概念: channel类似于socket句 ...
- bzoj2464 小明的游戏
Description 小明最近喜欢玩一个游戏.给定一个n * m的棋盘,上面有两种格子#和@.游戏的规则很简单:给定一个起始位置和一个目标位置,小明每一步能向上,下,左,右四个方向移动一格.如果移动 ...