<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic DMA interrupt  stops working in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/DMA-interrupt-stops-working/m-p/517021#M1971</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by justmakeit on Wed Sep 30 00:10:45 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have written a code to send/receive ip packets over rs485. Its (almost) working.The receiver is started with a uart interrupt and starts a dma transfer. When the dma is finished it should fire a interrupt but this not always the case. It stops firing dma interrupts after a random time. I checked if the dma cannel was still active with the function GPDMA_IntGetStatus(GPDMA_STAT_ENABLED_CH, 0) and it returned SET so it is still running. When i enable the uart irq it is still firing so there is data in the FIFO.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can i debug this problem? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you in advance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
//Interrupt function for the rs485 module
void RS485_IRQHandler(void)
{
if(UART_ReceiveByte((LPC_UART_TypeDef *) LPC_UART1) != 0x01){
return;
}
UART_RS485ReceiverCmd(LPC_UART1, ENABLE);
UART_Receive((LPC_UART_TypeDef *) LPC_UART1, received_data, 10, BLOCKING);
if((memcmp (&amp;amp;received_data[4], Net_settings.MAC_Address.addr, 6) == 0)||memcmp (&amp;amp;received_data[4], broadcast_mac, 6) == 0){
received_len = 0;
received_len |= (received_data[0] &amp;lt;&amp;lt; 24);
received_len |= (received_data[1] &amp;lt;&amp;lt; 16);
received_len |= (received_data[2] &amp;lt;&amp;lt; 8);
received_len |= (received_data[3]);

if(rs485_buffer != NULL){
free(rs485_buffer);
rs485_buffer = NULL;
}
rs485_buffer = malloc(received_len);
if(rs485_buffer == NULL){printf("rs485:malloc failed\r\n");}
memmove(rs485_buffer,&amp;amp;received_data[4],6);

GPDMA_Channel_CFG_Type GPDMAChannelConfig;
GPDMAChannelConfig.ChannelNum = 0;
GPDMAChannelConfig.TransferSize = received_len - 6;
GPDMAChannelConfig.DstMemAddr = (uint32_t)(&amp;amp;rs485_buffer[5]);
GPDMAChannelConfig.TransferType = GPDMA_TRANSFERTYPE_P2M;
GPDMAChannelConfig.SrcConn = GPDMA_CONN_UART1_Rx;
GPDMAChannelConfig.DMALLI = 0;
if(GPDMA_Setup(&amp;amp;GPDMAChannelConfig) == ERROR){printf("dma error\r\n");}

GPDMA_ChannelCmd(0, ENABLE);
NVIC_DisableIRQ (UART1_IRQn);
NVIC_EnableIRQ (DMA_IRQn);
}else{
UART_RS485ReceiverCmd(LPC_UART1, DISABLE);
}
}

void DMA_IRQHandler(void){
if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){
// Check counter terminal status
if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){
// Clear terminate counter Interrupt pending
GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
poll_eth_RS485_driver();
}
// Check error terminal status
if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){
// Clear error counter Interrupt pending
GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
free(rs485_buffer);
rs485_buffer = NULL;
printf("rs485: DMA error\n\r");
}
}
GPDMA_ChannelCmd(0, DISABLE);
UART_RS485ReceiverCmd(LPC_UART1, DISABLE);
NVIC_EnableIRQ (UART1_IRQn);

}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 17:27:54 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T17:27:54Z</dc:date>
    <item>
      <title>DMA interrupt  stops working</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/DMA-interrupt-stops-working/m-p/517021#M1971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by justmakeit on Wed Sep 30 00:10:45 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have written a code to send/receive ip packets over rs485. Its (almost) working.The receiver is started with a uart interrupt and starts a dma transfer. When the dma is finished it should fire a interrupt but this not always the case. It stops firing dma interrupts after a random time. I checked if the dma cannel was still active with the function GPDMA_IntGetStatus(GPDMA_STAT_ENABLED_CH, 0) and it returned SET so it is still running. When i enable the uart irq it is still firing so there is data in the FIFO.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can i debug this problem? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you in advance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
//Interrupt function for the rs485 module
void RS485_IRQHandler(void)
{
if(UART_ReceiveByte((LPC_UART_TypeDef *) LPC_UART1) != 0x01){
return;
}
UART_RS485ReceiverCmd(LPC_UART1, ENABLE);
UART_Receive((LPC_UART_TypeDef *) LPC_UART1, received_data, 10, BLOCKING);
if((memcmp (&amp;amp;received_data[4], Net_settings.MAC_Address.addr, 6) == 0)||memcmp (&amp;amp;received_data[4], broadcast_mac, 6) == 0){
received_len = 0;
received_len |= (received_data[0] &amp;lt;&amp;lt; 24);
received_len |= (received_data[1] &amp;lt;&amp;lt; 16);
received_len |= (received_data[2] &amp;lt;&amp;lt; 8);
received_len |= (received_data[3]);

if(rs485_buffer != NULL){
free(rs485_buffer);
rs485_buffer = NULL;
}
rs485_buffer = malloc(received_len);
if(rs485_buffer == NULL){printf("rs485:malloc failed\r\n");}
memmove(rs485_buffer,&amp;amp;received_data[4],6);

GPDMA_Channel_CFG_Type GPDMAChannelConfig;
GPDMAChannelConfig.ChannelNum = 0;
GPDMAChannelConfig.TransferSize = received_len - 6;
GPDMAChannelConfig.DstMemAddr = (uint32_t)(&amp;amp;rs485_buffer[5]);
GPDMAChannelConfig.TransferType = GPDMA_TRANSFERTYPE_P2M;
GPDMAChannelConfig.SrcConn = GPDMA_CONN_UART1_Rx;
GPDMAChannelConfig.DMALLI = 0;
if(GPDMA_Setup(&amp;amp;GPDMAChannelConfig) == ERROR){printf("dma error\r\n");}

GPDMA_ChannelCmd(0, ENABLE);
NVIC_DisableIRQ (UART1_IRQn);
NVIC_EnableIRQ (DMA_IRQn);
}else{
UART_RS485ReceiverCmd(LPC_UART1, DISABLE);
}
}

void DMA_IRQHandler(void){
if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){
// Check counter terminal status
if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){
// Clear terminate counter Interrupt pending
GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
poll_eth_RS485_driver();
}
// Check error terminal status
if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){
// Clear error counter Interrupt pending
GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
free(rs485_buffer);
rs485_buffer = NULL;
printf("rs485: DMA error\n\r");
}
}
GPDMA_ChannelCmd(0, DISABLE);
UART_RS485ReceiverCmd(LPC_UART1, DISABLE);
NVIC_EnableIRQ (UART1_IRQn);

}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:27:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/DMA-interrupt-stops-working/m-p/517021#M1971</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:27:54Z</dc:date>
    </item>
  </channel>
</rss>

