cancel
Showing results for 
Search instead for 
Did you mean: 

AN2598 smartcard interface example code

DGabc.1
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Guenael Cadier
ST Employee

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.

View solution in original post

3 REPLIES 3
Guenael Cadier
ST Employee

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
Associate III

Hi Guenael,

Thank you for explaining.

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

Best regards,

D.

@Community member​ 

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