Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ISO7816 interface using any PIC16

Status
Not open for further replies.

danny1331

Newbie level 4
Joined
Apr 20, 2010
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Japan
Activity points
1,358
Dear Anyone,

Have anyone tried to implement ISO7816 interface using any PIC16 or PIC16F1936 in particular.

Hoping to hear from anyone. Please help.

Thanks,
Danny
 

I haven't with a PIC, but I have from an ARM to a Smart Card Interface IC to a Smart Card.

Details required to determine how much that you can simplify your design:

#1 - What physical size of Smart Card? Credit Card size or SIM size like in phones?

#2 - Do you want to support live insertion of a Smart Card or will the SIM be installed prior to powerup?

#3 - What type of Smart Card do you want to target? One specific brand or model?

#4 - What protocols do you want to support? T=1, T=0, synchronous protocol.

#5 - Smart Card running at 1.8V, 3V, 5V? One specific voltage or any of them? Smart Cards can support 1 to 3 different voltages...which depends upon the specific model.

#6 - Does the voltage of your CPU I/O match any of the above voltages?

The more flexible that you need your design, the more likely you want to go with a Smart Card Interface chip that can support any voltage and protocol, but if you specific needs are very narrow and well defined then you might be able to optimize your design.

Added after 3 minutes:

The software protocol can be the biggest pain in the ass part of interfacing Smart Cards. If you are interfacing to one and only one model then it will be a lot easier. The ISO7816 protocol has lots of variations and it can be a big pain to support every smart card in existance.
 

Dear Enlightenment,

Thank you very much for your reply. All the requirements you've mentioned are satisfied.
This is the case and I want to explain further. I am working on this Dual-Interface Chip in which you write data by wireless interface and you read data by contact interface. Wireless interface is not a problem.
The problem is on the contact interface, when I tried to apply RESET to the Dual-Interface chip, the procedure to apply ISO7816-3 RESET is OK. The chip then replies the ATR(Answer-To-Reset) bytes but the problem is, I just couldn't receive the correct data bytes.
This has something to do on the timing on receiving the data bytes, I already tried some different solutions but it always gave the same result.
Is this have something to do for PIC MCU's in which clock cycles is always 1/4 of the PIC's oscillator frequency? Or some problem on my coding itself.
Any suggestions are very much welcome, by the way, I am using assembly in my coding to minimize the number of clock cycles.

Thanks and hoping some enlightenment from fellow members.
 

First make sure the signals to/from the Smart Card are correct. Use digital scope and logic analyzer to look at signals.

Verify:

- Power is stable.

- Clock is starting at proper time and stays running.

- You need to make sure Power, Clock, RST match the timing order as specified in ISO7816. Use logic analyzer to capture: VCC, CLK, RST, I/O.

- Use logic analyzer to capture some data bytes. Measure the timing width of a single bit to determine the baud rate. Make sure your baud rates match!

Added after 4 minutes:

Note: The smart card might be running self-tests so the time between ATR bytes can vary a lot. You might get some bytes then a long delay then more. Make sure your software assumes the worst timing between ATR bytes.

Added after 5 minutes:

I recommend you initially code in C and NOT care about the coding size. Once you get it running in C, then later you can convert to assembler. Smart Cards have lots of weird little issues, so you want to use a higher level language so you can quickly make changes.

Added after 4 minutes:

The Smart Card uses a fixed divisor to convert the incoming clock rate to the output data baud rate. If the clock is different than what you expect, then the data will come out at a higher or lower baud rate than you expect. Thus you should measure the clock frequency too.

Added after 4 minutes:

Note: The smart card will initially communicate at a default baud rate, then you can send it a command to change baud rates. The ATR is fixed at a default baud rate, because of the fixed divisor, thus can't be changed.
 

Dear Enlightenment,

Thanks again for your reply. Sorry for the late reply, I have been out of the office.

I really think all what you've mentioned are satisfied on my part. I have been testing and checking the output on the oscilloscope. The Dual-Chip replies the ATR but I just can't get receive correct databytes when debugging the PIC CPU. It's just a matter of correct timing issue.

I have already implemented the same assembly code with 2 other CPU's and it was successful. For the other CPU, I can send and receive correct databytes. I am pretty quite comfortable with assembly programming.

As to your suggestion to use C, I am not very good on it, I am just a novice programmer and still learning the ropes.
Is there any way you could help me and provide me a sample/starting C code for ISO7816-3 interface communication and I will work from there. Help me to get the correct databytes when receiving ATR bytes.

Rest assured if you can help me. Your effort will be thank in a way to make you happy.

Thank you very much,
Danny
Email me personally if you can for more details: danny@uscdiehards.org
 

Dear Enlightenment,

Just want to let you know that it is already working on my side. I solved the receiving of databytes timing issue.

Thank you very much,
Danny
 

Dear Enlightenment,

Just want to let you know that it is already working on my side. I solved the receiving of databytes timing issue.

Thank you very much,
Danny

Hi Danny,

I have the exact same problem you had...how did you solve it?

Thanks

Sam
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top