通过SPI2操作SD卡,用DMA1的4,5通道时可以正常工作,现在想换成DMA2的1,2通道操作,DMA2一直不工作做。难道DMA2只能用于SPI3?
#define SDC_DMA_RX_CH DMA2_Channel1 //使用DMA时接收SD卡数据的通道
#define SDC_DMA_TX_CH DMA2_Channel2 //使用DMA时向SD卡发送数据的通道
#define SDC_SPI_DR_Addr 0x4000380C //使用DMA时对应的SPI->DR的地址
#define SDC_DMA_RX_FLAG_TE DMA2_FLAG_TE1 //DMA接收通道传输错误标志位
#define SDC_DMA_RX_FLAG_TC DMA2_FLAG_TC1 //DMA接收通道传输结束标志位
#define SDC_DMA_TX_FLAG_TE DMA2_FLAG_TE2 //DMA发送通道传输错误标志位
#define SDC_DMA_TX_FLAG_TC DMA2_FLAG_TC2 //DMA发送通道传输结束标志位
#define SDC_SPI SPI2
DMA_DeInit(SDC_DMA_RX_CH);
st_sdcDmaInitStructure.DMA_PeripheralBaseAddr = (u32)SDC_SPI_DR_Addr;
st_sdcDmaInitStructure.DMA_MemoryBaseAddr = (u32)st_sdcTask.pc_buff;
st_sdcDmaInitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
st_sdcDmaInitStructure.DMA_BufferSize = 256;
st_sdcDmaInitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
st_sdcDmaInitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
st_sdcDmaInitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
st_sdcDmaInitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
st_sdcDmaInitStructure.DMA_Mode = DMA_Mode_Normal;
st_sdcDmaInitStructure.DMA_Priority = DMA_Priority_Low;
st_sdcDmaInitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(SDC_DMA_RX_CH, &st_sdcDmaInitStructure);
//发送通道设置
DMA_DeInit(SDC_DMA_TX_CH);
st_sdcDmaInitStructure.DMA_PeripheralBaseAddr = (u32)SDC_SPI_DR_Addr;
st_sdcDmaInitStructure.DMA_MemoryBaseAddr = (u32)st_sdcTask.pc_buff;
st_sdcDmaInitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
st_sdcDmaInitStructure.DMA_Priority = DMA_Priority_Low;
DMA_Init(SDC_DMA_TX_CH, &st_sdcDmaInitStructure);
SPI_I2S_DMACmd(SDC_SPI, SPI_I2S_DMAReq_Tx, ENABLE);
SPI_I2S_DMACmd(SDC_SPI, SPI_I2S_DMAReq_Rx, ENABLE);
DMA_Cmd(SDC_DMA_RX_CH, ENABLE); //先使能接收通道再使能发送通道
DMA_Cmd(SDC_DMA_TX_CH, ENABLE);
寄存器状态如下:感觉寄存器也没什么异常啊。
求大神指教一下,万分感谢!
|