本帖最后由 wds王王 于 2022-1-27 22:53 编辑
用STM32F103 SPI1 DMA发送数据是正常的。然后升级换成AT32F415 SPI1 DMA发送,DMA1_Channel3发送完中断可以进去,但实际上数据没有被正常解析到,在此基础上用AT32F415 SPI1轮循发送,就可以被正常解析,说明SPI1 的GPIO配制肯定没有问题,问题就出在DMA发送上,
AT32F415 的SPI1 DMA发送数据哪里要特殊配制吗?
RCC_AHBPeriphClockCmd(RCC_AHBPERIPH_DMA1, ENABLE);
DMA_ChannelEnable(DMA1_Channel3,DISABLE);
DMA_DefaultInitParaConfig(SPIx_DMA_Tx);
SPIx_DMA_Tx->DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DT);
SPIx_DMA_Tx->DMA_MemoryBaseAddr = (uint32_t)TxBuf;
SPIx_DMA_Tx->DMA_Direction = DMA_DIR_PERIPHERALDST;
SPIx_DMA_Tx->DMA_BufferSize = 32;
SPIx_DMA_Tx->DMA_PeripheralInc = DMA_PERIPHERALINC_DISABLE;
SPIx_DMA_Tx->DMA_MemoryInc = DMA_MEMORYINC_ENABLE;
SPIx_DMA_Tx->DMA_PeripheralDataWidth = DMA_PERIPHERALDATAWIDTH_BYTE;
SPIx_DMA_Tx->DMA_MemoryDataWidth = DMA_MEMORYDATAWIDTH_BYTE;
SPIx_DMA_Tx->DMA_Mode = DMA_MODE_NORMAL;
SPIx_DMA_Tx->DMA_Priority = DMA_PRIORITY_VERYHIGH;
SPIx_DMA_Tx->DMA_MTOM = DMA_MEMTOMEM_DISABLE;
DMA_Init(DMA1_Chx, SPIx_DMA_Tx);
SPI_I2S_DMAEnable(SPI1, SPI_I2S_DMA_TX, ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
DMA_INTConfig(DMA1_Channel3, DMA_INT_TC, ENABLE);
DMA_ChannelEnable(DMA1_Channel3, ENABLE);
|