I am working on an embedded device using a NXP LH79524 ARM7TDMI SOC processor.
My task is to convert the working data transmission through UART0 to use DMA.

We have a 2k buffer of formatted, ASCII data, and I want the DMA to transfer this data to UART0. We are going to profile the system to see if this is faster than the existing system and if it frees up execution time.

I have searched the web for examples and nothing comes up for the NXP LH79524 processor.
The User Manual is vague on the steps required to transmit data.

Here is my code, assume that the UART0 is already set up for character transmission:

typedef struct DMA_Data_Stream_Register_struct
{
    uint32_t    Source_Low;
    uint32_t    Source_High;
    uint32_t    Dest_Low;
    uint32_t    Dest_High;
    uint32_t    Maximum_Count;
    uint32_t    Control;
    uint32_t    Current_Srce_Addr_High;
    uint32_t    Current_Srce_Addr_Low;
    uint32_t    Current_Dest_Addr_High;
    uint32_t    Current_Dest_Addr_Low;
    uint32_t    Terminal_Count;
    uint32_t    reserved[4];
} DMA_Data_Stream_Register_t;

// ...
        //----------------------------------------------------------------------
        //  Initialize the DMA controller to use the UART.
        //  This is an experiment.
        //----------------------------------------------------------------------
      DMA_Data_Stream_Register_t volatile * const p_dma_uart_tx   = (DMA_Data_Stream_Register_t *) 0xFFFE10C0U;
      uint32_t volatile * const   p_dma_intr_mask_register        = (uint32_t *) 0xFFFE10F0U;
      uint32_t volatile * const   p_dma_intr_clear_register       = (uint32_t *) 0xFFFE10F4U;
      uint32_t volatile * const   p_dma_status_register           = (uint32_t *) 0xFFFE10F8U;
      uint32_t volatile * const   p_uart0_dma_control_register    = (uint32_t *) 0xFFFC0048U;
      static const char           dma_test_text[] = "\r\n\r\n*** Written by DMA ***\r\n\r\n";

        //----------------------------------------------------------------------
        //  Set up UART0 for DMA transfers
        //----------------------------------------------------------------------
      *p_uart0_dma_control_register = 0x02U; // Enable transmit DMA, a.k.a. TXDMAEN

        //----------------------------------------------------------------------
        //  Set up the source addresses for stream 0.
        //----------------------------------------------------------------------
      uint32_t    source_address = (uint32_t) &dma_test_text[0U];
      uint32_t    source_high = source_address >> 16;
      uint32_t    source_low  = source_address & 0xFFFFU;
      p_dma_uart_tx->Source_Low = source_low;
      p_dma_uart_tx->Source_High = source_high;
      p_dma_uart_tx->Current_Srce_Addr_High = source_high;
      p_dma_uart_tx->Current_Srce_Addr_Low = source_low;
      p_dma_uart_tx->Maximum_Count = sizeof(dma_test_text) - 1U;
      const uint32_t  dma_config =
            0x2000U /* Peripheral is destination */
          | 0x0000U /* DMA to Destination Data width, 0x00 == 1 byte */
          | 0x0000U /* Peripheral Burst Size, single == 0x00 */
          | 0x0002U /* Current Source Register increments */
              ;
      p_dma_uart_tx->Control = dma_config;

        //----------------------------------------------------------------------
        //  Start the DMA transfer.
        //----------------------------------------------------------------------
      p_dma_uart_tx->Control = dma_config | 0x01U;
      *p_uart0_dma_control_register = 0x02U; // Enable transmit DMA, a.k.a. TXDMAEN  

I am using IAR Embedded Workbench compiler / IDE.

When viewing the DMA registers via Watch Window, the source address is copied to the "current source" register. After waiting for a second, the 'current source" register is not incremented and the Terminal Count is still the original transmission size.

I'm not sure the order of enabling the DMA and the UART0. I have tried enabling DMA first, then UART0 TXDMAEN, and no characters came out. I tried enabling UART0 TXDMAEN first then enabling the DMA and no characters came out.

I'm looking for a working C language example of transmitting data to UART0 using DMA on the NXP LH79524 processor. Any pointers would be helpful.

有帮助吗?

解决方案

CTS and RTS are multiplexed with the DMA.

  1. Be sure CTS and RTS are enabled (CTSEN/RTSEN)
  2. Watch PB0 and PB1 status (nDACK0/CTS0) (nDREQ/RTS0)

On initiating a DMA operation the DMAC:CTRL:ENABLE bit should be set before either of the RXDMAEN or TXDMAEN bits are set.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top