cancel
Showing results for 
Search instead for 
Did you mean: 

Send data with usart in smart card mode and DMA

cordonnier
Associate II
Posted on July 16, 2013 at 00:26

Hi,

I'm trying to communicate with a smart card using the usart on a STM105RC. I was successful doing that with normal interrupts, and now I'm trying to use the DMA with the USART for better performance. My problem is that I can send the data and get a ''DMA transfer complete interrupt'', but I don't get a ''Usart transfer complete interrupt'' after that. But for a smart card it is very important to catch the USART_TC and not the DMA_TC, because as shown in the reference manual(RM0008, figure 295), the transfer is not terminated on the USART side when the DMA_TC arises and if I start reading data on the usart after DMA_TC I read the data that are being sent (RX connected to TX in smart card mode).

Are there some specific actions to take when using smart card mode and DMA on a USART?

I tried using DMA with a ''normal'' usart and I'm getting USART_TC interrupts, but that could be caused by the configuration difference between the 2 usarts.

I'm using the remapped Usart3 TX, that is DMA1 Channel2.

#usart-dma-smart-card-tc
2 REPLIES 2
Posted on July 16, 2013 at 00:59

I'm not aware of any magic for smart card mode, I've just used DMA on the USARTs in regular modes. I'd imagine you'd want to clear the USART TC flag, and then enable the USART TC interrupt from the DMA TC interrupt service.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
cordonnier
Associate II
Posted on July 16, 2013 at 20:59

Thank you very much for your answer, I changed two things to make it work:

1. Instead of activating DMA_TC and USART_TC interrupts at the same time in the code, I did like you said and activated only DMA_TC in the code, and then I activated USART_TC from the DMA_TC interrupt handler.

2. For some reasons I don't understand, I had to move the command to disable the usart dma_tx request and disable the dma channel in the DMA_TC interrupt handler. Once I did that I got some USART_TC interrupts, whereas before the disable commands were in the USART_TC handler but I was not getting a USART_TC interrupt.

Do those 2 points make any sense? I didn't understand I had to do that by reading the documentation.