cancel
Showing results for 
Search instead for 
Did you mean: 

I can not get atr by using of st's code

hasan bucak
Associate II
Posted on September 12, 2017 at 14:11

Hi, I am new to stm and I have STM32L053R8 - NUCLEO, I have to make a smartcard project with this.

I am using prepared code by given ST Firm and a smartcard. When I debug the code , it stucks.

 the code of smartcard project is 

http://www.st.com/en/embedded-software/x-cube-smcard.html

I have been trying to get ATR for 1 mounth, but it stucks in code-1

 I entered inside of atr_read and tried to find the problem, I think that the problem is about HAL_TIMEOUT.

is there anyone who can help me to solve this ?

I put here code that I believed the problem is linked with (code-2). 

Please help me

code-1

/* Read ATR - loop until it's read */

do

{

atr_size = sizeof(atr_buff);

}

while (HAL_OK != ATR_Read(&SCInterface, atr_buff, &atr_size)); // it does not get out of here

code-2 

if(SMARTCARD_WaitOnFlagUntilTimeout(hsc, SMARTCARD_FLAG_RXNE, RESET, Timeout) != HAL_OK) 

{

return HAL_TIMEOUT;

}

#smartcard #stm32l053r8-nucleo #stm32l053 #cube-mx
5 REPLIES 5
Posted on September 12, 2017 at 16:09

>>I have been trying to get ATR for 1 month, but it sticks in code-1

Perhaps look more critically about why this would fail or the card not respond. Look at what happens earlier, and perhaps use a different card.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on September 13, 2017 at 15:51

Actually, I looked into the whole codes but I couldn't find out the problem for certain. It stucks in 

SMARTCARD_WaitOnFlagUntilTimeout(hsc, SMARTCARD_FLAG_RXNE, RESET, Timeout) != HAL_OK

The project was utterly prepared by St Firms,as I shared the link of project above, and my knowledge of code is not enough to understand clearly. By the way, I tried 3 different cards but nothing changed.

Posted on September 13, 2017 at 16:38

>>The project was utterly prepared by ST

You could perhaps discuss this with your local FAE, either at your distributor, or ST office. There might be some contractors or consultants on their list specializing in smart card applications.

You'll need to rework the looping code to limit the retries, unwind, and recover when the card isn't responding as desired. Most code is provided for demonstrational purposes, and will need to be worked on to deliver a commercial solution.

>>my knowledge of code is not enough to understand clearly

You'll need to familiarize yourself with the protocol and interactions, and review the signals and responses on a logic-analyzer to better understand why the timeout might be occurring

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on September 14, 2017 at 15:34

I think , I found the problem, the problem is that TDA8034 hasn't sent the Vcc to pin of C1(card supply). Thats why , software couln't communucate with smartcard to get the atr.

But there is a new question =) 

why doesn't it send Vcc ?

Thank you for helping

Posted on September 14, 2017 at 16:48

Look at how the TDA8034 or equivalent part is used on EVAL boards supporting the card currently. Look at whatever pins from the STM32 are controlling it, replicate that in your design, and make sure you port the pin config code to match what you've built vs the examples.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..