STM32F7开发板,做SPI DMA传输试验,参照光盘视频例程,DMA配置代码如下。
有个问题咨询一下。。
DMA传输的源地址、目的地址要如何配置?因为确定了DMA流以及通道所以可以底层自己匹配到SPI2的接收Buf吗?
void myDMA_Init(void)
{
SPI_HandleTypeDef SPI2_Handler;
DMA_InitTypeDef DMA_InitStructure;
DMA_HandleTypeDef DMA1_Handler;
__HAL_RCC_DMA1_CLK_ENABLE();
__HAL_LINKDMA(&SPI2_Handler, hdmarx, DMA1_Handler);
HAL_DMA_DeInit(&DMA1_Handler);
DMA1_Handler.Instance = DMA1_Stream3;
DMA1_Handler.Init.Channel = DMA_CHANNEL_0;
DMA1_Handler.Init.Direction = DMA_PERIPH_TO_MEMORY;
DMA1_Handler.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
DMA1_Handler.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
DMA1_Handler.Init.MemBurst = DMA_MBURST_INC4;
DMA1_Handler.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
DMA1_Handler.Init.MemInc = DMA_MINC_ENABLE;
DMA1_Handler.Init.Mode = DMA_NORMAL;
DMA1_Handler.Init.PeriphBurst = DMA_PBURST_INC4;
DMA1_Handler.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
DMA1_Handler.Init.PeriphInc = DMA_PINC_DISABLE;
DMA1_Handler.Init.Priority = DMA_PRIORITY_MEDIUM;
HAL_DMA_Init(&DMA1_Handler);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
貌似大家用的都是下面这套内容。。。
DMA_InitTypeDef DMA_InitStructure;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(&(SD_SPI->DR));
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //!!!
DMA_InitStructure.DMA_BufferSize = 0; //!!!
DMA_InitStructure.DMA_Channel = SD_DMA_RX_CHANNEL;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)0; //!!!
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_Init(SD_DMA_RX_STREAM, &DMA_InitStructure);
一周热门 更多>