AM13E23019: UART DMA Issue TXIFG Observed before Enabling DMA

Part Number: AM13E23019
Other Parts Discussed in Thread: UNIFLASH

Hi 

I am observing issues with DMA configuration. 
Goal

Transmit the data from txbuffer using DMA and Receive the data using DMA into the rxbuffer. I am not using the Tx and Rx FIFO thresholds. 

Configurations for UART5 (specifying important and nondefault values)

  • Baud Rate : 5M
  • RX Timeout Interrupt Counts : 15 
  • DMA RX Trigger : UART RX Interrupt
  • DMA TX Trigger : UART TX Interrupt
  • Tx Pin : A22 | Rx Pin : A10 | UC5

TX DMA : APP_DMACH_UC5_TX


RX DMA : APP_DMACH_UC5_RX

 

 
#define MML_TX_BUFFER_SIZE (90)
#define MML_RX_BUFFER_SIZE (128)

uint8_t txbuffer[MML_TX_BUFFER_SIZE] = {0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16, 17,
                                                18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
                                                36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
                                                54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
                                                72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89};
uint8_t rxbuffer[MML_RX_BUFFER_SIZE];

int main()
{
    Diag_InitCounters(); // Clear the counters used for debugging 
    
    Device_Init();

    /* Resetting the DMA Channels */
    DL_DMA_resetChannel(APP_DMACH_UC5_TX_DMA_INST, APP_DMACH_UC5_TX_CHANNEL_ID);
    DL_DMA_resetChannel(APP_DMACH_UC5_RX_DMA_INST, APP_DMACH_UC5_RX_CHANNEL_ID);

    DL_UART_reset(APP_UART_0_INST);
    SYSCFG_DL_init();
    
    /* Clear TX and RX Fifo */
    UC5_UART->IFLS |=  0x88;

    /* Clearing all pending interrupts for UART */
    DL_UART_clearInterruptStatus(APP_UART_0_INST, 0xFFFFFFFF);

    /* TX DMA Configuration */
    DL_DMA_setSrcAddr(APP_DMACH_UC5_TX_DMA_INST, APP_DMACH_UC5_TX_CHANNEL_ID, (uint32_t)txbuffer);
    DL_DMA_setDestAddr(APP_DMACH_UC5_TX_DMA_INST, APP_DMACH_UC5_TX_CHANNEL_ID, (uint32_t)&UC5_UART->TXDATA);
    DL_DMA_setTransferSize(APP_DMACH_UC5_TX_DMA_INST, APP_DMACH_UC5_TX_CHANNEL_ID, MML_TX_BUFFER_SIZE);
    DL_DMA_enableChannel(APP_DMACH_UC5_TX_DMA_INST, APP_DMACH_UC5_TX_CHANNEL_ID);

    /* RX DMA Configuration */
    DL_DMA_setSrcAddr(APP_DMACH_UC5_RX_DMA_INST, APP_DMACH_UC5_RX_CHANNEL_ID, (uint32_t)&UC5_UART->RXDATA);
    DL_DMA_setDestAddr(APP_DMACH_UC5_RX_DMA_INST, APP_DMACH_UC5_RX_CHANNEL_ID, (uint32_t)rxbuffer);
    DL_DMA_setTransferSize(APP_DMACH_UC5_RX_DMA_INST, APP_DMACH_UC5_RX_CHANNEL_ID, MML_RX_BUFFER_SIZE);
    DL_DMA_enableChannel(APP_DMACH_UC5_RX_DMA_INST, APP_DMACH_UC5_RX_CHANNEL_ID);

    /* For Logic Analyser Time Marking */
    BSP_AM13E230_E2::Debug10Pin_Low();
    DEVICE_DELAY_MS(100);
    BSP_AM13E230_E2::Debug10Pin_High();
    DEVICE_DELAY_MS(100);
    BSP_AM13E230_E2::Debug10Pin_Low();

    soft_timer1.Start(); /* 1ms loop */
    soft_timer2.Start(); /* 10ms loop */
    soft_timer3.Start(); /* 100ms loop */
    soft_timer4.Start(); /* 1000ms loop */
    
    // DL_UART_disable(APP_UART_0_INST);
    // DL_UART_enableDMATransmitEvent(APP_UART_0_INST);
    // DL_UART_enable(APP_UART_0_INST);

    LOG("Entering While Loop \r\n");
    while (1)
    {
        g_diagCounters.mainLoopCnt++;
        
        /* Run all timers periodically */
        us32 currentTime = Millis::GetMs();
        soft_timer1.PeriodicRun(currentTime);
        soft_timer2.PeriodicRun(currentTime);
        soft_timer3.PeriodicRun(currentTime);
        soft_timer4.PeriodicRun(currentTime);
    }
    return 0;
}



I am triggering the UART DMA by calling this function in one second loop 

DL_UART_transmitData(APP_UART_0_INST, txbuffer[0]);



I am first testing with UART Tx DMA and I observe following issues 

  • The DMA start sending the data as soon as I enable the DMA  during initialisation process. It should have waiting untill I manually send one byte to start triggering for further buffer transmission. I checked the Interrupt flag and TXIFG flag is set when checking the debug mode before the enable channel was done. 
  • Dont know if it related or not but Somehow 3 Launchpad Debugger section (MCU is fine) have gone bad while debugging UART DMA ( 1- E1 Launchpad, 2- E2 Launchpad) 
  • Hi Dheeraj,

    Which TX FIFO level setting do you have configured in the IFLS.TXIFLSEL field of the UC-UART? This is the condition that will trigger the TX DMA. I believe default selection for the TX FIFO level is "not full". The UC_TX trigger will indeed be flagged as soon as the TX FIFO empty condition is present then, which is the case on startup. Once the DMA is enabled, the trigger is propagated to the DMA and the transfer begins. This is actually the expected behavior. I would suggest waiting to enable the DMA channel for the UX_TX DMA until you are ready for the first UART transmit to happen. 

    Dont know if it related or not but Somehow 3 Launchpad Debugger section (MCU is fine) have gone bad while debugging UART DMA ( 1- E1 Launchpad, 2- E2 Launchpad) 

    Could you elaborate more on the above? What do you mean by "gone bad"? Note that you may have to reconnect the debugger fully sometimes after doing many rebuild/reload/restart sequences. 

    Best Regards,

    Delaney

  • Also to note, with the DMA enabled, you shouldn't have to do software writes to the TX FIFO. If you are having both DMA and CPU write the TX buffer, you may see some corrupted or out of order data. I would suggest first getting everything working as expected without DMA enabled (just DL_UART_transmitData writes), then migrating to a DMA approach and seeing if the behavior matches. You don't want to use both DMA and non-DMA code at the same time. 

    Best Regards,

    Delaney

  • I was debugging the UART code and the LP stopped going into Debug mode but MCU is fine as he LED blink still happening. I am getting the following errors

    This one is when i try to use uniflash 
     



    This one is when trying to use debugger 

  • I have to keep it enabled during configurations itself as in my actual application, I am using multiple DMA to implement a custom protocol. Here are some of the details. I will discuss only the transmit part first. I have the following DMAs implemented.
    1. Master DMA(Software Tigger, Starts timer for 24us in one shot mode. This used for custom protocol implementation)

    2. Start Commincation (Triggered by Master DMA, single mode, fix add to fix add,   Writes First byte of tx buffer into the TXDATA so that next DMA can send the data)

    3. UC5 Transmit(Triggered by UC5_TX, block add to fix add, writes the data from txbuffer[1] to TXDATA. Now the communication can take place further)

    The setup works but the first frame sends out as soon as the UC5 Transmit is enabled. I dont want that to happen. I would like to start it when I trigger the Master DMA from Software when i have filled my txbuffer. 

    I could have sent you some of the logic analyser timing events but my boards are getting bad, so I have now limited no of boards to do experiments. 

    Which TX FIFO level setting do you have configured in the IFLS.TXIFLSEL field of the UC-UART? 
    default i.e. no thresholds

    I would suggest waiting to enable the DMA channel for the UX_TX DMA until you are ready for the first UART transmit to happen. 
    in SDK, there is no example for DMA UART TX and RX. 
    DMA enabling and Trigger is 2 different things, I shall be able to control the DMA by Trigger only. It should not fire when I enable the DMA Channel (I understand why it is getting fired as you explained in the previous post). as you are mentioning that I should not send it manually, I did it so that UC5 Transmit DMA will get the trigger and start the communication. 
    Can you tell an alternative approcach for my application ? 
    I mean for transmitting with DMA, what shall be the trigger and how to start the DMA ?

    while writing this, I think I should enable the UC5 transmit DMA using Start Communication DMA operation instead of doing it during configuraiton. Please confirm, and if possible then please add UART DMA example in some of the thread untill new SDK comes out

  • Hi Dheeraj,

    Can you please follow these steps in this FAQ:

     [FAQ] AM13E23019: Not able to connect the AM13x device . Error connecting target error -615 

    This should help you resolve the Debugger connection errors.

    Regards,
    Shaunak

  • Hi Shaunak
    For me it is not showing any scripts

  • Hi Dheeraj,

    What version of CCS are you using? Is the AM13E230x LP connected to your laptop with the BSL button held?

    Regards,
    Shaunak

  • Hi Shaunak, earlier connected on USB and didnt connect to target using  AM13.ccxml file. 

    once i connected then it started showing the scripts, the board is fixed by performing the steps, Thanks