This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Generating ISO/IEC 7816 Clock

TM4C123GXL Datasheet states that UARTs are ISO 7816 compatible but checking with oscilloscope shows that it is of the same frequency as the frequency that one bit is sent. ISO/IEC 7816-3:2006 standard says that I have to have clock that is 372 times faster than the clock used for bit transmission (Elementary Time Unit, ETU). I would like to know if there is an easy way to implement such CLK and synchronise CLK and I/O lines if there's a need to use and additional timer

  • Hello Arturas

    Do you mean the internal clock of the UART peripheral needs to be 372 times faster or the CLK on the pins?
  • Arturas Jonkus said:
    it is of the same frequency as the frequency that one char is sent

    UART clock will be the same as the frequency that one BIT is sent, not one full char.

    And there will only be a change on the signal if the previous bit is opposite the current one. Otherwise, there will be no change on the signal.

    Further, such clock, as far as I understand, must simply respect the data rate agreed between the devices on both ends... Provided that this is met, the clock and dividers used above it do not impact UART communication, ain't that right?

  • Bruno, corrected my mistake.

    Amit, baud rate should be 9600, but additional clock which is sinchronised with this one should be 372 times faster, according to specification. As I understand from TM4C123GPM datasheet, clock on PB1 will be of the same speed as baud rate. I'm trying to find a way to setup proper clock conforming to specification of ISO/IEC-7816-3:2006
  • Hello Arturas

    The Clock being generated on the UnTX pin is correct for the baud rate. However I believe the actual clock should for the interface should be generated separately to meet the requirements as per the specification. I am not too sure at this time and running the same with some of colleagues
  • Arturas,
    It appears to me that you are referring to an external clock signal sent to the card, which has nothing to do with the uart communication itself.
    Should you need a TM4 to generate a clock that is 372 * 9600 (3.57MHz) I suggest you use a pwm signal (or a timer). If you run your TM4C123 at its max (80MHz), flip the signal either every 22 cycles (3.63MHz) or every 23 (3.48MHz). Both probably meet your requirements. If you run your MCU at 50MHz and set the PWM at 14 cycles, you will be VERY close to what you are looking for.
    Or maybe I did not understand what your goal is...
    Regards
    Bruno
  • If you could advise me on something that would be nice. I am now considering a PLL but am not sure how to synchronize IO and my generated Clock lines in phase.
  • Will try your solution and see if it works. Problem could be synchronisation so I should probably use the same clock for UART and ClK generation
  • Trust me, working with the MCU at 50MHz, the rate you can obtain is so close to what you need, that I suspect that the standard was done with such clock in mind...
    The rate between the theoretical value and the obtained one is 1.00006400!
    And your 9600 will still be 9600.
    Cheers,
    Bruno
  • Hello Arturas

    As Bruno mentioned, you could also use a timer in PWM mode to generate a PWM signal which meets the clock requirement. The UART signals are generated from the system clock, so they would be in phase.
  • Generated a clock using PWM where period is 14 ticks and duty cycle is 7 ticks. Frequency seems roughly okay, answer to reset byte sequence seems to be sent when checked with oscilloscope and but reading symbols doesn't work. Probably will get it to work after some debugging.


    *edit - I can confirm that fequency is 3.571 Mhz and duty cycle is 50 percent.  Added TimerControlLevel(TIMER1_BASE,    TIMER_A, 1); to make sure that pwm is sinchronised with main clock. Tried redirecting chars from this UART to UART0 which is connected to computer with no success.

    *edit no.2 - Turned off Smart Card mode and shorted RX and TX pins and I seem to be getting Answer to Reset, 15 bytes. So yeah, I think, this case is answered and closed.

  • Hello Arturas

    Thank you for the confirmation.