嵌入式技术william hill官网
直播中

张龙祥

9年用户 1269经验值
擅长:连接器
私信 关注
[问答]

请问stm32f429的uart8 dma收发不能正常工作怎么解决?

在rtt studio平台,芯片是STM32f429,串口3和串口4配置接收中断或者DMA模式都OK;串口8配置中断接收模式,收发都OK,但是配置成DMA模式该串口8不工作(发送和接收都没有)。
求助:将串口8配置成DMA收发模式可以正常工作。






/* 串口485方向GPIO设置 */
    rt_pin_mode(rs485_dir1, PIN_MODE_OUTPUT);
    rt_pin_write(rs485_dir1, PIN_LOW);
    /* 查找串口设备 */
    u2_dev = rt_device_find("uart2");

回帖(2)

最强海贼王

2022-5-24 15:04:12
驱动配置没写完
举报

建立建利12

2022-5-24 15:04:47
drv_usart.c文件中stm32_uart_get_dma_config只配置了uart1~6的DMA,uart7和uart8需要自己加一下

static void stm32_uart_get_dma_config(void)

{

#ifdef BSP_USING_UART1

    uart_obj[UART1_INDEX].uart_dma_flag = 0;

#ifdef BSP_UART1_RX_USING_DMA

    uart_obj[UART1_INDEX].uart_dma_flag |= RT_DEVICE_FLAG_DMA_RX;

    static struct dma_config uart1_dma_rx = UART1_DMA_RX_CONFIG;

    uart_config[UART1_INDEX].dma_rx = &uart1_dma_rx;

#endif

#ifdef BSP_UART1_TX_USING_DMA

    uart_obj[UART1_INDEX].uart_dma_flag |= RT_DEVICE_FLAG_DMA_TX;

    static struct dma_config uart1_dma_tx = UART1_DMA_TX_CONFIG;

    uart_config[UART1_INDEX].dma_tx = &uart1_dma_tx;

#endif

#endif

#ifdef BSP_USING_UART2

    uart_obj[UART2_INDEX].uart_dma_flag = 0;

#ifdef BSP_UART2_RX_USING_DMA

    uart_obj[UART2_INDEX].uart_dma_flag |= RT_DEVICE_FLAG_DMA_RX;

    static struct dma_config uart2_dma_rx = UART2_DMA_RX_CONFIG;

    uart_config[UART2_INDEX].dma_rx = &uart2_dma_rx;

#endif

#ifdef BSP_UART2_TX_USING_DMA

    uart_obj[UART2_INDEX].uart_dma_flag |= RT_DEVICE_FLAG_DMA_TX;

    static struct dma_config uart2_dma_tx = UART2_DMA_TX_CONFIG;

    uart_config[UART2_INDEX].dma_tx = &uart2_dma_tx;

#endif

#endif

#ifdef BSP_USING_UART3

    uart_obj[UART3_INDEX].uart_dma_flag = 0;

#ifdef BSP_UART3_RX_USING_DMA

    uart_obj[UART3_INDEX].uart_dma_flag |= RT_DEVICE_FLAG_DMA_RX;

    static struct dma_config uart3_dma_rx = UART3_DMA_RX_CONFIG;

    uart_config[UART3_INDEX].dma_rx = &uart3_dma_rx;

#endif

#ifdef BSP_UART3_TX_USING_DMA

    uart_obj[UART3_INDEX].uart_dma_flag |= RT_DEVICE_FLAG_DMA_TX;

    static struct dma_config uart3_dma_tx = UART3_DMA_TX_CONFIG;

    uart_config[UART3_INDEX].dma_tx = &uart3_dma_tx;

#endif

#endif

#ifdef BSP_USING_UART4

    uart_obj[UART4_INDEX].uart_dma_flag = 0;

#ifdef BSP_UART4_RX_USING_DMA

    uart_obj[UART4_INDEX].uart_dma_flag |= RT_DEVICE_FLAG_DMA_RX;

    static struct dma_config uart4_dma_rx = UART4_DMA_RX_CONFIG;

    uart_config[UART4_INDEX].dma_rx = &uart4_dma_rx;

#endif

#ifdef BSP_UART4_TX_USING_DMA

    uart_obj[UART4_INDEX].uart_dma_flag |= RT_DEVICE_FLAG_DMA_TX;

    static struct dma_config uart4_dma_tx = UART4_DMA_TX_CONFIG;

    uart_config[UART4_INDEX].dma_tx = &uart4_dma_tx;

#endif

#endif

#ifdef BSP_USING_UART5

    uart_obj[UART5_INDEX].uart_dma_flag = 0;

#ifdef BSP_UART5_RX_USING_DMA

    uart_obj[UART5_INDEX].uart_dma_flag |= RT_DEVICE_FLAG_DMA_RX;

    static struct dma_config uart5_dma_rx = UART5_DMA_RX_CONFIG;

    uart_config[UART5_INDEX].dma_rx = &uart5_dma_rx;

#endif

#ifdef BSP_UART5_TX_USING_DMA

    uart_obj[UART5_INDEX].uart_dma_flag |= RT_DEVICE_FLAG_DMA_TX;

    static struct dma_config uart5_dma_tx = UART5_DMA_TX_CONFIG;

    uart_config[UART5_INDEX].dma_tx = &uart5_dma_tx;

#endif

#endif

#ifdef BSP_USING_UART6

    uart_obj[UART6_INDEX].uart_dma_flag = 0;

#ifdef BSP_UART6_RX_USING_DMA

    uart_obj[UART6_INDEX].uart_dma_flag |= RT_DEVICE_FLAG_DMA_RX;

    static struct dma_config uart6_dma_rx = UART6_DMA_RX_CONFIG;

    uart_config[UART6_INDEX].dma_rx = &uart6_dma_rx;

#endif

#ifdef BSP_UART6_TX_USING_DMA

    uart_obj[UART6_INDEX].uart_dma_flag |= RT_DEVICE_FLAG_DMA_TX;

    static struct dma_config uart6_dma_tx = UART6_DMA_TX_CONFIG;

    uart_config[UART6_INDEX].dma_tx = &uart6_dma_tx;

#endif

#endif

}
举报

更多回帖

发帖
×
20
完善资料,
赚取积分