I have configured a blackfin BF537 as a SPI Slave device, and use DMA to receive data from a different microcontroller.
DMA is using autobuffer, and is set up with 2 buffers of 512bytes each.
The SPI/DMA init function looks like this: (buffer is unsigned short, BUFF_SIZE = 256, BUFF_NUM = 2 ).
unsigned char byte;
*pDMA7_CONFIG = 0;
*pDMA7_START_ADDR = buffer;
*pDMA7_X_COUNT = BUFF_SIZE;
*pDMA7_Y_COUNT = BUFF_NUM;
*pDMA7_X_MODIFY = 2;
*pDMA7_Y_MODIFY = 2;
*pDMA7_CONFIG = DMAEN | WNR | WDSIZE_16 | DMA2D | DI_SEL | DI_EN | NDSIZE_0 | FLOW_AUTO ;
*pSPI_CTL = TIMODE(2) | CPOL | CPHA | SIZE;
*pSIC_IMASK |= IRQ_DMA7;
register_handler (ik_ivg10, SPI_DMA7_ISR);
*pSPI_CTL |= SPE;
byte = *pSPI_RDBR;
if (*pSIC_ISR & SPI_IRQ)
*pDMA7_IRQ_STATUS |= DMA_DONE;// clear DMA IRQ
while(!(*pSPI_STAT & SPIF));//Wait for SPI to complete last data transaction
dmadone = true;
*pDMA7_CONFIG &= ~DMAEN; // Disable DMA
*pSPI_CTL &= ~SPE; // Disable SPI
void initPORTS( void )
*pPORTF_FER |= SPI_MOSI | SPI_SCLK | SPI_SSEL1;
*pSPI_FLG |= FLS1;
This works fine as long as there is SPI data coming in when I start up the program. However, if the SPI data stream is stopped for some reason, I can not stop and reset DMA. If I do, it all looks like garbage data until I cycle power and restart the program.
How do you stop peripheral DMA using autobuffer and start it up again at any time?
Calling stopDMASPI() followed by initSPIdataDMA() is just not working.