Discussion:
Smart card baud rate/clock speed
(too old to reply)
galapogos
2006-10-20 10:00:14 UTC
Permalink
Hi,

I'm trying to write a software iso7816 implementation via UART on a
generic 16-bit MCU. Due to the clockspeed of my MCU, I'm unable to
generate a 9600bps baudrate on the UART. I'm also having trouble
getting a 3.5712MHz clock to the smart card due to the Fd=372 and Dd =
1 that doesn't work very well with the MCU's prescalar, and also
because I can't seem to find any 3.5712MHz crystals around. I know
smart cards generally work from 1-5MHz, but the initial clock should be
3.5712MHz. I'm wondering if it would be ok to start running the smart
card at some other clock frequency, say 4MHz?

Thanks!
Chris
2006-10-20 17:27:40 UTC
Permalink
Hello,

There is no pb to start at 4MHz. The speed will a bit higher than 9600b/s
but who care about that ? The card uses etu (372 etu in fact to exchange one
bit of ATR), in total independance of the used clock. As ssoon as the card's
chip support the clock you provide, there is no problem.

Chris


"galapogos" <***@gmail.com> a écrit dans le message de news:
***@f16g2000cwb.googlegroups.com...
Hi,

I'm trying to write a software iso7816 implementation via UART on a
generic 16-bit MCU. Due to the clockspeed of my MCU, I'm unable to
generate a 9600bps baudrate on the UART. I'm also having trouble
getting a 3.5712MHz clock to the smart card due to the Fd=372 and Dd =
1 that doesn't work very well with the MCU's prescalar, and also
because I can't seem to find any 3.5712MHz crystals around. I know
smart cards generally work from 1-5MHz, but the initial clock should be
3.5712MHz. I'm wondering if it would be ok to start running the smart
card at some other clock frequency, say 4MHz?

Thanks!
galapogos
2006-10-21 05:30:54 UTC
Permalink
Post by Chris
Hello,
There is no pb to start at 4MHz. The speed will a bit higher than 9600b/s
but who care about that ? The card uses etu (372 etu in fact to exchange one
bit of ATR), in total independance of the used clock. As ssoon as the card's
chip support the clock you provide, there is no problem.
Chris
Hi,
I'm trying to write a software iso7816 implementation via UART on a
generic 16-bit MCU. Due to the clockspeed of my MCU, I'm unable to
generate a 9600bps baudrate on the UART. I'm also having trouble
getting a 3.5712MHz clock to the smart card due to the Fd=372 and Dd =
1 that doesn't work very well with the MCU's prescalar, and also
because I can't seem to find any 3.5712MHz crystals around. I know
smart cards generally work from 1-5MHz, but the initial clock should be
3.5712MHz. I'm wondering if it would be ok to start running the smart
card at some other clock frequency, say 4MHz?
Thanks!
Thanks! That's good news. It'd be easier to find a clock that both the
MCU and smart card can share then I think.
Chris
2006-10-21 16:47:15 UTC
Permalink
You corrected yourself : the card (and the reader) use 372 clock cycles
(1etu) and not 372 etu to exchange 1 bit ! I write as I speak, too fast ;-)

Chris
Post by Chris
Hello,
There is no pb to start at 4MHz. The speed will a bit higher than 9600b/s
but who care about that ? The card uses etu (372 etu in fact to exchange one
bit of ATR), in total independance of the used clock. As ssoon as the card's
chip support the clock you provide, there is no problem.
Chris
Thanks! That's good news. It'd be easier to find a clock that both the
MCU and smart card can share then I think.
galapogos
2006-10-22 03:44:56 UTC
Permalink
Post by Chris
You corrected yourself : the card (and the reader) use 372 clock cycles
(1etu) and not 372 etu to exchange 1 bit ! I write as I speak, too fast ;-)
Chris
Haha ok. Yeah I know it only takes 1 ETU. I've done some homework on
the protocol :)

Anyway, I don't suppose it's possible to change the initial value of Fd
right? Is that done via PPS if both the reader/card support it?
Chris
2006-10-22 10:35:57 UTC
Permalink
You're partially right. The default etu is always 372 clock ticks during the
ATR. After, it depends...

If the card is in negociable mode, you may use a PPS to move to a shorter
etu (a higher speed). The card always support the speed it annouces in TA1,
ans sometime other ones...

If the card is in Specific mode, it uses directly after the ATR the speed it
announces in TA1, without any need to exchange a PPS. Very few cards are
in specific mode but your driver will have to support it for this minority
:-(

I do not remember where in ATR the card says it is in specific or negociable
mode (I'm at home), but if you have the 7816, you will find it easily. For
ATR analyse (and every smart card dialog) I use EasyReader, a software you
can get there in its free version :
http://www.edsi-smartcards.com/page_type_ang.php?rubr=0&ssrubr=&no_menu=1&lien=telechargement_ang.htm&librubr=Download&LangueID=2

An other issue you will meet is the T=0 character error management, but if
your MCU is very close to the smartcard, transmission error will never
occur. In a very first time, you can try without any error management...

Good work :-)

Chris
Post by Chris
You corrected yourself : the card (and the reader) use 372 clock cycles
(1etu) and not 372 etu to exchange 1 bit ! I write as I speak, too fast ;-)
Chris
Haha ok. Yeah I know it only takes 1 ETU. I've done some homework on
the protocol :)

Anyway, I don't suppose it's possible to change the initial value of Fd
right? Is that done via PPS if both the reader/card support it?
galapogos
2006-10-22 12:46:25 UTC
Permalink
Post by Chris
You're partially right. The default etu is always 372 clock ticks during the
ATR. After, it depends...
If the card is in negociable mode, you may use a PPS to move to a shorter
etu (a higher speed). The card always support the speed it annouces in TA1,
ans sometime other ones...
If the card is in Specific mode, it uses directly after the ATR the speed it
announces in TA1, without any need to exchange a PPS. Very few cards are
in specific mode but your driver will have to support it for this minority
:-(
I do not remember where in ATR the card says it is in specific or negociable
mode (I'm at home), but if you have the 7816, you will find it easily. For
ATR analyse (and every smart card dialog) I use EasyReader, a software you
http://www.edsi-smartcards.com/page_type_ang.php?rubr=0&ssrubr=&no_menu=1&lien=telechargement_ang.htm&librubr=Download&LangueID=2
An other issue you will meet is the T=0 character error management, but if
your MCU is very close to the smartcard, transmission error will never
occur. In a very first time, you can try without any error management...
Good work :-)
Chris
Cool, I'll check it out. I don't have the ISO7816 docs with me right
now either, but I can check them tomorrow. Anyway, I don't actually
want to deal with PPS. The default baud rate is absolutely fine with
me, as my data transfers are very simple and don't require a lot of
bandwidth. I'm guessing I don't have to do anything special during ATR
or anywhere else if I want to stick with the default baudrate?

My MCU will also be pretty near the smart card, so it's good to hear
about the error management part. I did however already code the error
management part in...I just haven't tested it yet :)
Chris
2006-10-22 18:40:50 UTC
Permalink
Nothing special to do during ATR, but perhaps an etu adjustment to to do
after ATR (to the one given by TA1) if the card is in SPECIFIC mode instead
of NEGOCIABLE one.

Concerning error management, it can be hard to test. Some card simulator
exist (have a look at http://www.smartware.fr or
http://micropross.vintel.eu) but it can be expensive for a selfmade
smartcard communication system...

Have a nice work :-)




"galapogos" <***@gmail.com> a écrit dans le message de news:
***@e3g2000cwe.googlegroups.com...
Cool, I'll check it out. I don't have the ISO7816 docs with me right
now either, but I can check them tomorrow. Anyway, I don't actually
want to deal with PPS. The default baud rate is absolutely fine with
me, as my data transfers are very simple and don't require a lot of
bandwidth. I'm guessing I don't have to do anything special during ATR
or anywhere else if I want to stick with the default baudrate?

My MCU will also be pretty near the smart card, so it's good to hear
about the error management part. I did however already code the error
management part in...I just haven't tested it yet :)

Continue reading on narkive:
Search results for 'Smart card baud rate/clock speed' (Questions and Answers)
11
replies
How did the the Internet get started?
started 2007-02-11 06:06:14 UTC
trivia
Loading...