AnsweredAssumed Answered

BF518 SPORT/DMA re-start.

Question asked by alemannia on Sep 27, 2013
Latest reply on Oct 16, 2013 by alemannia

Hi,

 

I am configuring the SPORT(0) to transmit and receive data using DMA. That works perfectly well. The problem appears when I decide to stop the SPORT/DMA and then re-start it again.

 

/* Stop the SPORT channels. */

*pSPORT0_TCR1 &= ~TSPEN; // TX

ssync();

*pSPORT0_RCR1 &= ~RSPEN; // RX

ssync();

 

/* Stop DMA */

*pDMA4_CONFIG &= ~DMAEN;

ssync();

*pDMA3_CONFIG &= ~DMAEN;

ssync();

 

Then - some time later - I re-configure the DMA and re-start the SPORT.

 

/* Configure DMA4 (TX) */

*pDMA4_NEXT_DESC_PTR  = 0;

*pDMA4_START_ADDR     = (void*)_tx_dma;

*pDMA4_X_COUNT        = _DMA_PACKET_SIZE_WORDS;

*pDMA4_X_MODIFY       = 4;

*pDMA4_Y_COUNT        = 2;

*pDMA4_Y_MODIFY       = 4;

ssync();

 

*pDMA4_CONFIG = FLOW_AUTO |

                NDSIZE_0 |

                DI_EN |

                DI_SEL |

                DMA2D |

                WDSIZE_32 |

                /* WNR | */

                DMAEN;

ssync();

 

/* configure DMA3 (RX) */

*pDMA3_NEXT_DESC_PTR  = 0;

*pDMA3_START_ADDR     = (void*)_rx_dma;

*pDMA3_X_COUNT        = _DMA_PACKET_SIZE_WORDS;

*pDMA3_X_MODIFY       = 4;

*pDMA3_Y_COUNT        = 2;

*pDMA3_Y_MODIFY       = 4;

ssync();

 

*pDMA3_CONFIG = FLOW_AUTO |

                NDSIZE_0 |

                DI_EN |

                DI_SEL |

                DMA2D |

                WDSIZE_32 |

                WNR |

                DMAEN;

ssync();

 

/* Enable SPORT channels */

*pSPORT0_TCR1 |= TSPEN; // TX

ssync();

*pSPORT0_RCR1 |= RSPEN; // RX

ssync();

 

On the BF side I always put a magic word (0xDEADBEEF) at the beginning of each DMA buffer:


0xDEADBEEF

0x00000000

0x00000000

0x00000000

...


It happens sometimes that the target (SHARC) will receive one extra word before the 0xDEADBEEF magic:

 

0x00000000 <-- ?

0xDEADBEEF

0x00000000

0x00000000

...

 

It looks like the SPORT (TX) FIFO is not being reset when disabled. I suspect that if the SPORT has been disabled while transmitting data, then re-enabling the port some time later will send out remaining word(s) in the FIFO first.

 

What would be the correct way of stopping and re-starting a SPORT/DMA configuration?

 

Thanks.

 

 




Outcomes