大家好,我最近遇到一个问题,SPI2 DMA 接受不到数据,不知道哪里遇到了问题,向大神们请教一下。比较急,谢谢! 下面是我的代码: DCMI 通过DMA给 SPI发数据,DCMI有数据发出,且数据正确。但是SPI没有接受到数据,且LCD没有显示摄像头端的数据(spi2驱动LCD是ok的)。 DCMI端代码:这是ok的通过FSMC验证过。 DMA_InitTypeDef DMA_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; //spi tx -> DMA_Channel_3 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2,ENABLE); DMA_DeInit(DMA2_Stream1);//µÈ´ýDMA2_Stream1 while (DMA_GetCmdStatus(DMA2_Stream1) != DISABLE){} DMA_InitStructure.DMA_Channel = DMA_Channel_1; //ͨµÀ1 DCMIͨµÀ DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&DCMI->DR; DMA_InitStructure.DMA_Memory0BaseAddr = (u32)&SPI2->DR; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = DMA_BufferSize; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA2_Stream1, &DMA_InitStructure); SPI DMA端配置代码: void SPI2_DMAInit (void) { DMA_InitTypeDef DMA_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1, ENABLE); DMA_DeInit(DMA1_Stream3); DMA_DeInit(DMA1_Stream4); while (DMA_GetCmdStatus(DMA1_Stream3) != DISABLE){printf("-");} DMA_InitStructure.DMA_Channel = DMA_Channel_0; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(&(SPI2->DR)); DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)SPI_RXBUFFER; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = 1; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA1_Stream3, &DMA_InitStructure); // DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)SPI_TXBUFFER; // // DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; // DMA_InitStructure.DMA_BufferSize = 8; // // DMA_InitStructure.DMA_Priority = DMA_Priority_Low; // DMA_Init(DMA1_Stream4, &DMA_InitStructure); SPI_I2S_DMACmd(SPI2, SPI_I2S_DMAReq_Tx, ENABLE); SPI_I2S_DMACmd(SPI2, SPI_I2S_DMAReq_Rx, ENABLE); DMA_ITConfig(DMA1_Stream3, DMA_IT_TC | DMA_IT_TE, ENABLE); DMA_ITConfig(DMA1_Stream4, DMA_IT_TC | DMA_IT_TE, ENABLE); NVIC_InitTypeDef NVIC_InitStructure; NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannel =ENABLE; NVIC_Init(&NVIC_InitStructure); DMA_Cmd(DMA1_Stream3, ENABLE); DMA_Cmd(DMA1_Stream4, ENABLE); printf("DMA 000 \n"); } void DMA1_Stream3_IRQHandler (void) { if (DMA_GetITStatus(DMA1_Stream3, DMA_IT_TCIF3) == SET) { DMA_ClearFlag(DMA1_Stream3, DMA_IT_TC); DMA_ClearFlag(DMA1_Stream4, DMA_IT_TC); DMA_ClearITPendingBit(DMA1_Stream3, DMA_IT_TCIF3); DMA_ClearITPendingBit(DMA1_Stream4, DMA_IT_TCIF4); SPI_I2S_DMACmd(SPI2, SPI_I2S_DMAReq_Tx, DISABLE); SPI_I2S_DMACmd(SPI2, SPI_I2S_DMAReq_Rx, DISABLE); printf("DMA 111 \n"); } printf("DMA 222 \n"); } |
STM32F407 定时器触发DMA 求助大神
【MCU实战经验】基于STM32F407的音频播放器设计
盘古UE-STM32F407工控板原理图
【STM32F429心得\疑问】+STM32F4之FSMC和FMC
STM32F429读取IO口传输的数据速率
STM32F407ZGT6 手摸芯片背部重启
STM32F4 SPI 动作时,软件片选信号被拉高,IO口程序逻辑失控
STM32F401RE NUCLEO求助,串口一直不能进中断
读取STM32F407内部温度传感器值错误
STM32F429多路内部ADC独立采集的办法
这一句有问题啊,RAM地址怎么写成SPI寄存器了?