[STM32F4] stm32f407 sdio 4bit dma

[复制链接]
3530|5
 楼主| ginuobili11 发表于 2015-11-16 11:26 | 显示全部楼层 |阅读模式
在使用stm32cubemx stm32407的sdio 4bit dma操作sd卡时,dma中断老是进入半传输中断,然后就不正常。
有那位大侠知道什么事半传输中断,用uart dma就不会出这个问题,中断是直接跳到传输完成中断。

dma配置如下有问题嘛?

hdma_sdio_rx.Instance = DMA2_Stream3;
    hdma_sdio_rx.Init.Channel = DMA_CHANNEL_4;
    hdma_sdio_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
    hdma_sdio_rx.Init.PeriphInc = DMA_PINC_DISABLE;
    hdma_sdio_rx.Init.MemInc = DMA_MINC_ENABLE;//DMA_MINC_DISABLE;//
    hdma_sdio_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
    hdma_sdio_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
    hdma_sdio_rx.Init.Mode = DMA_NORMAL;
    hdma_sdio_rx.Init.Priority = DMA_PRIORITY_LOW;
    hdma_sdio_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
    hdma_sdio_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
    hdma_sdio_rx.Init.MemBurst = DMA_MBURST_SINGLE;
    hdma_sdio_rx.Init.PeriphBurst = DMA_PBURST_SINGLE;
 楼主| ginuobili11 发表于 2015-11-16 11:33 | 显示全部楼层
有谁知道半传输中断是怎么产生的嘛?
feihufuture 发表于 2015-11-16 11:33 | 显示全部楼层
注意清中断,,,这个版块好热闹啊,,,,,
 楼主| ginuobili11 发表于 2015-11-16 11:51 | 显示全部楼层
谢谢,feihufuture的回答。看了下有清这个中断
/* Clear the half transfer complete flag */
        __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma));
         /* Disable the half transfer interrupt if the DMA mode is not CIRCULAR */
        if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0)
        {
          /* Disable the half transfer interrupt */
          __HAL_DMA_DISABLE_IT(hdma, DMA_IT_HT);
        }
      

        /* Change DMA peripheral state */
        hdma->State = HAL_DMA_STATE_READY_HALF_MEM0;


有没有可能是别的问题,我不理解什么情况下会进入这个半传输中断
 楼主| ginuobili11 发表于 2015-11-16 11:52 | 显示全部楼层
本帖最后由 ginuobili11 于 2015-11-16 11:56 编辑

从程序调试看会一直卡在这个地方
while((__HAL_SD_SDIO_GET_FLAG(hsd, SDIO_FLAG_RXACT)) && (timeout > 0))
  {
    timeout--;  
  }

SDIO_FLAG_RXACT 为1表示数据接收正在进行中(状态寄存器)
 楼主| ginuobili11 发表于 2015-11-16 17:27 | 显示全部楼层
参考https://bbs.21ic.com/forum.php?mo ... peid%26typeid%3D350
搞定,但是很多东西还是不明白。

修改了sdio dma的配置如下:

  hdma_sdio_rx.Init.Channel             = DMA_CHANNEL_4;
  hdma_sdio_rx.Init.Direction           = DMA_PERIPH_TO_MEMORY;
  hdma_sdio_rx.Init.PeriphInc           = DMA_PINC_DISABLE;
  hdma_sdio_rx.Init.MemInc              = DMA_MINC_ENABLE;
  hdma_sdio_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
  hdma_sdio_rx.Init.MemDataAlignment    = DMA_MDATAALIGN_WORD;
  hdma_sdio_rx.Init.Mode                = DMA_PFCTRL;
  hdma_sdio_rx.Init.Priority            = DMA_PRIORITY_VERY_HIGH;
  hdma_sdio_rx.Init.FIFOMode            = DMA_FIFOMODE_ENABLE;
  hdma_sdio_rx.Init.FIFOThreshold       = DMA_FIFO_THRESHOLD_FULL;
  hdma_sdio_rx.Init.MemBurst            = DMA_MBURST_INC4;
  hdma_sdio_rx.Init.PeriphBurst         = DMA_PBURST_INC4;
同时注销 // while(hsd->SdTransferCplt == 0)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

5

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部