2012-01-16 07:56 AM
Hello all,
I am using DMA to manage the TX line of one USART (RX stays on standard interrupt). I have no problem with a RS232 tranceiver. But when I use a RS485 tranceiver I got a problemwith the CBUS line management. I manage this output in the DMA_IT_TC interrupt. It appears that the interrupt comes 2 characters before the real end of the transmission, and so my last 2 characters are cutted by the tranceiver. I fund that if I wait for the end of transmission on the USART peripheral like that :while
(USART_GetITStatus(cUARTPeriphDesc[eUART_PERIPH_USART3].Base, USART_IT_TC)
EQ RESET)
the problem is solved, but I don't want to use infinite loop. I think there is somewhere a settings I have forgot ... Do you have an idea ?
Thanks
Thomas
STM32F103
#dma #uart #usart-dma-rs485
2012-01-16 09:04 AM
Don't bother with the DMA TC interrupt, use the USART TC interrupt instead, as it signals when the last bit leaves the USART shift register, not when the last byte gets placed in the USART's holding register (TXE) at ~16 bit cycles before TC for 8-bit bytes.
2012-01-17 02:25 AM
Thank you for your answer Clive1.
If I enable the USART TC interrupt, the DMA does not work anymore. Maybe a problem of DMA settings ? Moreover, the USART TC interrupt occurs after each bytes transmission, and I want to avoid that. That's why I am trying to use the DMA on this usart (only one interrupt at the end of transfert). I think I will rather use a timer to change my input state after the transmission.2012-01-17 07:20 AM
Use the interrupts in tandem. Wait for the DMA interrupt first, and then enable the UART end of transmission interrupt in the DMA service routine. That way you know when the transmiter is finished and you can turn around the RS-485 transceiver safely.
Jack Peacock2012-02-09 03:00 AM
Thanks for your help, all is working fine now.
Thomas2012-02-13 01:37 AM
Hi thomas,
Maybe you can share (a part of) your code, it's not clear to me how you did it. Thanks, Evert