调试H743 DMA传输的时候,每次中断都是因为传输错误标志(TEIF)置位引起的。
我的目的是从外部FIFO(片选FMC_NE2,地址0X64000000),把16000个半字(16位)搬移到内部RAM(起始地址0X24001000)。
程序如下:
/**
* Enable DMA controller clock
* Configure DMA for memory to memory transfers
* hdma_memtomem_dma1_stream0
*/
static void MX_DMA_Init(void)
{
// DMA controller clock enable
__HAL_RCC_DMA1_CLK_ENABLE();
// Configure DMA request hdma_memtomem_dma1_stream0 on DMA1_Stream0
hdma_memtomem_dma1_stream0.Instance = DMA1_Stream0;
hdma_memtomem_dma1_stream0.Init.Request = DMA_REQUEST_MEM2MEM; //内存到内存
hdma_memtomem_dma1_stream0.Init.Direction = DMA_MEMORY_TO_MEMORY; //内存到内存
hdma_memtomem_dma1_stream0.Init.PeriphInc = DMA_PINC_DISABLE; //外设地址不变
hdma_memtomem_dma1_stream0.Init.MemInc = DMA_MINC_ENABLE; //内存地址自动增加
hdma_memtomem_dma1_stream0.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; //半字
hdma_memtomem_dma1_stream0.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; //半字
hdma_memtomem_dma1_stream0.Init.Mode = DMA_NORMAL; //普通DMA传输
hdma_memtomem_dma1_stream0.Init.Priority = DMA_PRIORITY_HIGH; //优先级高
hdma_memtomem_dma1_stream0.Init.FIFOMode = DMA_FIFOMODE_ENABLE; //FIFO使能
hdma_memtomem_dma1_stream0.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_1QUARTERFULL;
hdma_memtomem_dma1_stream0.Init.MemBurst = DMA_MBURST_SINGLE; //单次突发传输
hdma_memtomem_dma1_stream0.Init.PeriphBurst = DMA_PBURST_SINGLE; //单次突发传输
if (HAL_DMA_Init(&hdma_memtomem_dma1_stream0) != HAL_OK)
{
Error_Handler( );
}
// DMA interrupt init
// DMA1_Stream0_IRQn interrupt configuration
HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn);
}
//FIFO中断 外部中断1 PB1
void EXTI1_IRQHandler(void)
{
/* USER CODE BEGIN EXTI1_IRQn 0 */
/* USER CODE END EXTI1_IRQn 0 */
DisADsample(); //停止AD数据往FIFO里写
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1);
/* USER CODE BEGIN EXTI1_IRQn 1 */
HAL_DMA_Start_IT(&hdma_memtomem_dma1_stream0, 0x64000000, 0x24001000, 16000);//启动传输,源地址为0x64000000,
/* USER CODE END EXTI1_IRQn 1 */
}
// dma传输完成中断处理
void DMA1_Stream0_IRQHandler(void)
{
HAL_DMA_IRQHandler(&hdma_memtomem_dma1_stream0);
/* USER CODE BEGIN DMA1_Stream0_IRQn 1 */
if(__HAL_DMA_GET_FLAG(&hdma_memtomem_dma1_stream0,DMA_FLAG_TCIF0_4))//判断是否为DMA传输完成中断
{
__HAL_DMA_CLEAR_FLAG(&hdma_memtomem_dma1_stream0,DMA_FLAG_TCIF0_4);//清除中断标志位
HAL_DMA_Abort_IT(&hdma_memtomem_dma1_stream0); //传输完成以后关闭DMA
}
}
问题描述:
1、H743可以采集到FIFO输出半满中断信号,并可以触发EXTI1中断。
2、EXTI1中断处理程序EXTI1_IRQHandler里启动DMA传输,传输完成触发中断。
3、DMA中断每次由TEIF0触发。
请各位老师帮忙解决一下这个问题!谢谢!
|