BF531的SPI的DMA问题
DMA设定为实际接收字节数时,DMA使能后,总是检测到DMA在运行,也即在数据传送完毕后,DMA还在运行,此时可以检测到当前传送计数已经变为0了,为什么DMA还不停止?另外一个问题,如果把DMA设定计数减少4个的话,DMA就可以停止,为什么?
DMA初始化代码如下:
void InitDMARead(unsigned CHAR * pDstBuf, unsigned int uiNumBytesToRead)
{
// Set destination address for DMA
*pDMA5_START_ADDR = pDstBuf;
// Set the count to read in the DMA
*pDMA5_X_COUNT = uiNumBytesToRead;
*pDMA5_X_MODIFY = 1;
// Set the DMA Enable bit, Increment Destination, Don’t Increment Source, 8-bit Trasnfers
*pDMA5_CONFIG = 0x0003; //DMA enable, 8 bit transfer, write operation
// Initialize the SPI PORT: Slave, 8-bit Xfer, Clock SPI Opposite
*pSPI_CTL = 0x4412; //spi slave, spi 8 bit, DMA reciever
// DMA is now ready to receive the data...
}
DMA读程序
void FPSGetTESTImage (unsigned CHAR * pDstBuf)
{
// Initialize and enable the DMA engine
InitDMARead(pDstBuf, 1703);
// Send "Get TEST Image" command to the sensor
FPSWriteData(0x82);
FPSWriteData(0x40); // Enable Operations
FPSWriteData(0x80);
FPSWriteData(0x04); // Enable Operations
FPSWriteData(0x88);
FPSWriteData(0x02); // change to 32uS column scan
FPSWriteData(0xA2);
FPSWriteData(0x02); // Force Finger On (simulate touching)
FPSWriteData(0x98);
FPSWriteData(0x2A); // Enable Histogram data
FPSWriteData(0xAA);
FPSWriteData(0x10); // image = 31 byte repeating pattern after E0 HEADER:
FPSWriteData(0xAB);
FPSWriteData(0x00);
FPSWriteData(0x81);
FPSWriteData(0x44); // Request 1 image slice
//while (*pDMA5_CURR_X_COUNT != 0)
/* while ((*pDMA5_IRQ_STATUS & DMA_RUN) != 0)
{
printD(".");
printD("%4X\n",*pDMA5_IRQ_STATUS);
printD("%4X\n",*pDMA5_CURR_X_COUNT);
ezDelay(1);
}
*/
ezDelay(3);
printD("%4X\n",*pDMA5_IRQ_STATUS);
printD("%4X\n",*pDMA5_CURR_X_COUNT);
*pDMA5_CONFIG = 0x0002; //DMA disable, 8 bit transfer, write operation
printD("%4X\n",*pDMA5_IRQ_STATUS);
// Now the TEST image data is available in the data buffer
}