Skip to main content
DGabc.1
Associate III
June 9, 2023
Solved

AN2598 smartcard interface example code

  • June 9, 2023
  • 2 replies
  • 2128 views

Hello,

I am looking at the smartcard example application - https://github.com/STMicroelectronics/STM32CubeG4/tree/master/Projects/STM32G474E-EVAL/Examples/SMARTCARD/SMARTCARD_T0_MFX

In the project .ioc file, I see that the Baud Rate is set to 10752 Bits/s, and the smartcard clock frequency is 3.863636 MHz.

How was that baud rate calculated/determined, considering the above clock frequency?

Thank you,

D.

This topic has been closed for replies.
Best answer by Guenael Cadier

Hi @Community member​ 

I'm trying to explain the method, even if I think the baudrate in the example has to be adjusted.

In your project, you have USART3 clocked with PCLK2 at 170Mhz. On this, a Prescaler (value 22) is applied, leading to have SCLK signal supplied to Smartcard equal to 170/(22*2) => 3.86Mhz.

At startup, communication with smartcard will be based on a F/D ratio of 372/1 (372 clock cycles per etu). This 372/1 ratio in G4 SMARTCARD ip (USART3) is achieved by implementing a corresponding baudrate of 3.863636/372 => 10386.

So in my opinion, I think the exact value of the baudrate to be set in USART3 configuration in Smartcard mode, with a initial clock of 170Mhz, a prescaler equal to 44 (22*2), should be 10386 (rather than 10752).

10752 is applied in case of SCLK at 4Mhz. with 3.86Mhz, 10386 is better.

Hope this helps.

2 replies

Guenael Cadier
Guenael CadierBest answer
ST Employee
June 9, 2023

Hi @Community member​ 

I'm trying to explain the method, even if I think the baudrate in the example has to be adjusted.

In your project, you have USART3 clocked with PCLK2 at 170Mhz. On this, a Prescaler (value 22) is applied, leading to have SCLK signal supplied to Smartcard equal to 170/(22*2) => 3.86Mhz.

At startup, communication with smartcard will be based on a F/D ratio of 372/1 (372 clock cycles per etu). This 372/1 ratio in G4 SMARTCARD ip (USART3) is achieved by implementing a corresponding baudrate of 3.863636/372 => 10386.

So in my opinion, I think the exact value of the baudrate to be set in USART3 configuration in Smartcard mode, with a initial clock of 170Mhz, a prescaler equal to 44 (22*2), should be 10386 (rather than 10752).

10752 is applied in case of SCLK at 4Mhz. with 3.86Mhz, 10386 is better.

Hope this helps.

DGabc.1
DGabc.1Author
Associate III
June 9, 2023

Hi Guenael,

Thank you for explaining.

I was calculating 10386 as well, and was confused why the demo uses 10752.

Best regards,

D.

Guenael Cadier
ST Employee
June 12, 2023

@Community member​ 

FYI, I submitted an internal ticket (154558) to get this corrected in next STM32Cube G4 package.