cancel
Showing results for 
Search instead for 
Did you mean: 

Emul usart AN4457 issue

PCu1
Senior

Hello,

Has anyone ever used the emulated usart provided by ST (AN4457) based on timer and DMA?

I need it for transmit, not for reception.

In my test, most of the time TX characters are corrupted, sometimes it works.

I checked with scope and it appears that the startBit is missing, but the rest of the byte is correct.

Here example with the 'a', white trace is the correct one, yellow is the measured trace.

0693W000001rvWYQAY.bmp

It seems that the Start bit is present in the 'calculated' buffer for DMA, but the timer overflow early...

Thank you,

Pierre

14 REPLIES 14
PCu1
Senior

Thank you for your quick reply.

Ok It explains. And according the datasheet TIM1 is the only possibility on DMA2.

By chance TIM1.CC1 was not used on my project. And other TIM1.CCx are used for 0-10V generation so changing the frequency (increasing) was not a problem.

I will check again the datasheet because I didn't find information about BSRR + DMA1

Pierre

Fig 1 - DMA1 has no connectivity to AHB buses including the one where GPIO sits.

UART Tx can be implemented also in a different way, using a TIMx_CHy pin as output, toggling it using Output compare in Toggle mode with precalculated TIMx_CCRy values, autoloaded by DMA triggered by that same compare. That method can be pulled out using DMA1. It's the same as generating arbitrary waveform with timer - there are examples for that in Cube, and it's described in some appnote (maybe the timer cookbook?).

JW

PCu1
Senior

Yes, you are right.

On figure 23 it is expanded:

0693W000001sVJaQAM.png

Thank you for the tips using Timer Channel + DMA. Not possible for the actual project but for the future it could be a solution.

Thanks again,

Pierre

mshoj.1
Associate

Dear ST commute

HI,

I want make echo serial with uart emulation.

I want receive data from terminal and send it back (echo) with DMA uart emulation.

I was use the AN4457 example code, the issue is when use receiver and transmitter for just once , everything is ok . but put this code in while for continuous echo , stm32 after echo first time will hang.

please guide me for find a solution. 0693W00000Dm1opQAB.jpg0693W00000Dm1riQAB.jpg 

>>stm32 after echo first time will hang. please guide me for find a solution.

Does it just go to the ErrorHandler() to die there? Perhaps handle the error conditions.

Might want to try a solution that receives data at an individual byte level, and concurrently sends back the byte(s) it has accumulated, rather than this larger buffer ping-pong arrangement you have now.

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