AnsweredAssumed Answered

AN3070 : Is DMA transfer complete interrupt needed?

Question asked by king.derek on May 27, 2013
Latest reply on May 31, 2013 by king.derek
Application note AN3070 describes a procedure for releasing RS485 bus when using DMA to transfer USART data.   The procedure uses two interrupts:
  * DMA transfer complete (DMA_TC) interrupt 
  * USART transfer complete (USART_TC) interrupt.


In the app note, the DMA_TC is used to enable the USART_TC interrupt and the USART_TC interrupt is use to release the RS485 bus.  


However, the DMA_TC interrupt seems unnecessary.  I have code that only uses the USART_TC interrupt and works just fine.  Is there some subtle reason for using the DMA_TC interrupt to enable the USART_TC interrupt?




Here's my pseudo code that does not use the DMA_TC interrupt:


init()
{
  init_usart();
  init_dma(); //sets DMA type and direction but does not enable DMA
  enable_usart_tc_interrupt();
}


void rs485_write(uint8_t *data, int len)
{
  assert_rs485_write_enable():
  disable_dma();
  clear_dma_interrupt_flags();
  DMA->NTDR = len;
  DMA->M0AR = (uint32_t)data;
  enable_dma();
}  


void usart_tc_isr()
{
   deassert_rs485_write_enable();
   clear_usart_tc_flag();
   asm("nop"); // Adds a tiny bit of delay after clearing USART_TC that prevents interrupt from being re-entered immediately after returning
}




Link to app-note:
(http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/CD00249778.pdf?s_searchtype=keyword)

Outcomes