通过udma 控制uart rx 到ram数据传输问题.

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

 //  ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0);

   //

   // Configure the UART communication parameters.

   //

   ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200,

                           UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |

                           UART_CONFIG_PAR_NONE);

IntMasterEnable();

   //

   // Set GPIO A0 and A1 as UART pins.

   //

   GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

   //

   // Set both the TX and RX trigger thresholds to 4.  This will be used by

   // the uDMA controller to signal when more data should be transferred.  The

   // uDMA TX and RX channels will be configured so that it can transfer 4

   // bytes in a burst when the UART is ready to transfer more data.

   //

   ROM_UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8);

   //

   // Enable the UART for operation, and enable the uDMA interface for both TX

   // and RX channels.

   //

   ROM_UARTEnable(UART0_BASE);

// ROM_UARTIntEnable(UART0_BASE, UART_INT_RX );//| UART_INT_RT);

   ROM_UARTDMAEnable(UART0_BASE, UART_DMA_RX);

ROM_uDMAChannelEnable(UDMA_CHANNEL_UART0RX);

   //

   // This register write will set the UART to operate in loopback mode.  Any

   // data sent on the TX output will be received on the RX input.

   //

 //  HWREG(UART0_BASE + UART_O_CTL) |= UART_CTL_LBE;

   //

   // Enable the UART peripheral interrupts.  Note that no UART interrupts

   // were enabled, but the uDMA controller will cause an interrupt on the

   // UART interrupt signal when a uDMA transfer is complete.

   //

   ROM_IntEnable(INT_UART0);

   //

   // Put the attributes in a known state for the uDMA UART0RX channel.  These

   // should already be disabled by default.

   //

   ROM_uDMAChannelAttributeDisable(UDMA_CHANNEL_UART0RX,

                                   UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST |

                                   UDMA_ATTR_HIGH_PRIORITY |

                                   UDMA_ATTR_REQMASK);

   //

   // Configure the control parameters for the primary control structure for

   // the UART RX channel.  The primary contol structure is used for the "A"

   // part of the ping-pong receive.  The transfer data size is 8 bits, the

   // source address does not increment since it will be reading from a

   // register.  The destination address increment is byte 8-bit bytes.  The

   // arbitration size is set to 4 to match the RX FIFO trigger threshold.

   // The uDMA controller will use a 4 byte burst transfer if possible.  This

   // will be somewhat more effecient that single byte transfers.

   //

   ROM_uDMAChannelControlSet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT,

                             UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 |

                             UDMA_ARB_4);

   //

   // Configure the control parameters for the alternate control structure for

   // the UART RX channel.  The alternate contol structure is used for the "B"

   // part of the ping-pong receive.  The configuration is identical to the

   // primary/A control structure.

   //

//   ROM_uDMAChannelControlSet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT,

//                             UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 |

//                              UDMA_ARB_4);

   //

   // Set up the transfer parameters for the UART RX primary control

   // structure.  The mode is set to ping-pong, the transfer source is the

   // UART data register, and the destination is the receive "A" buffer.  The

   // transfer size is set to match the size of the buffer.

   //

   ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_PRI_SELECT,

                              UDMA_MODE_PINGPONG,

                              (void *)(UART0_BASE + UART_O_DR),

                              g_ucRxBufA, sizeof(g_ucRxBufA));

   //

   // Set up the transfer parameters for the UART RX alternate control

   // structure.  The mode is set to ping-pong, the transfer source is the

   // UART data register, and the destination is the receive "B" buffer.  The

   // transfer size is set to match the size of the buffer.

   //

   ROM_uDMAChannelTransferSet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT,

                              UDMA_MODE_PINGPONG,

                              (void *)(UART0_BASE + UART_O_DR),

                              g_ucRxBufB, sizeof(g_ucRxBufB));

  ROM_uDMAChannelAttributeEnable(UDMA_CHANNEL_UART0RX, UDMA_ATTR_USEBURST);

ROM_uDMAChannelEnable(UDMA_CHANNEL_UART0RX);

问题   正常现象,应该是,通过PC串口发送数据,udma将uart数据传输到数组后,产生uart 中断,提示传输完成,但是本人发送后,没有产生中断.请问是什么样原因呢?

  • 你好,按照你所描述的正常现象 应该是通过DMA的传输中断来提示你传输完成,而并非使用UART中断来进行提示。

  • 楼主,例程没有错,你只要把例程的下面这句屏蔽掉,不让UART运行在loopback模式下,

    //HWREG(UART0_BASE + UART_O_CTL) |= UART_CTL_LBE;

    然后使能相关引脚的GPIO功能(具体该使能什么引脚请看看芯片的datasheet),例程就能够正常的通过UART用UDMA接收发送,中断会发生在UART的中断子程序中:

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

       SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

       GPIOPinConfigure(GPIO_PE4_U0RX);

       GPIOPinConfigure(GPIO_PE5_U0TX);

       GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);

  • 楼主用的是什么器件?不知道是否会用到mux,使用GPIOPinConfigure可以将器件管脚配置为相应的功能,确认是否需要这些语句。另外楼主需要使能UART模块的中断,程序中的被注释掉了:

    ROM_UARTIntEnable(UART0_BASE, UART_INT_RX );

    建议先脱离DMA,调试好UART以后再加上DMA。

  • 楼主的问题是通过UART DMA进行乒乓模式下的数据接收,结果没有看到中断。需要检查或者注意的问题:

    1.UART的PIN脚配置是否正确。如果PIN脚有复用,需要配置       
             ROM_ GPIOPinConfigure(GPIO_PA1_U0TX);
             ROM_GPIOPinConfigure(GPIO_PA0_U0RX);

    2.你没有配置交替结构属性
    //   ROM_uDMAChannelControlSet(UDMA_CHANNEL_UART0RX | UDMA_ALT_SELECT,
    //                             UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 |
    //                              UDMA_ARB_4);

    3.这行代码不需要
           ROM_uDMAChannelAttributeEnable(UDMA_CHANNEL_UART0RX, UDMA_ATTR_USEBURST); 

    4.使能中断,要放在DMA配置完成之后
    ROM_UARTEnable(UART0_BASE);
    // ROM_UARTIntEnable(UART0_BASE, UART_INT_RX );//| UART_INT_RT);       
    ROM_UARTDMAEnable(UART0_BASE, UART_DMA_RX);
    ROM_uDMAChannelEnable(UDMA_CHANNEL_UART0RX); 

    5.配置完成后,你是否让代码进去等待接受的状态?

    6.DMA接收的数据没有达到你设定的数据是不会产生中断的,他没有串口FIFO的超时中断。除非数据收满或产生其他异常

     

     

  • 我也遇到这个问题了。uart1正常工作其他uart口都进不了断电。