Author Topic: UART DMA Defines  (Read 4825 times)

Offline AlexS

  • Newbie
  • *
  • Posts: 46
    • View Profile
UART DMA Defines
« on: May 24, 2018, 02:32:36 PM »
Hi,

Just started working with the Kinetis version of uTasker and first task is to get UART running with DMA and RX in free-running mode. Anyway, dug into the Tty_drv.c and found this bit:

Code: [Select]
#if defined SERIAL_SUPPORT_DMA_                                          // {18}
            if (ptTTYQue->ucDMA_mode & UART_TX_DMA) {
                QUEUE_TRANSFER reduction = (ptTTYQue->lastDMA_block_length - fnRemainingDMA_tx(channel)); // get the number of characters
                ptTTYQue->tty_queue.chars -= reduction;
                ptTTYQue->lastDMA_block_length -= reduction;
                ptTTYQue->tty_queue.put += reduction;
                if (ptTTYQue->tty_queue.put >= ptTTYQue->tty_queue.buffer_end) {
                    ptTTYQue->tty_queue.put -= ptTTYQue->tty_queue.buf_length;
                }
            }
#endif

Problem I'm seeing is that SERIAL_SUPPORT_DMA_ is not defined anywhere in the app_hw_kinetis.h header, but SERIAL_SUPPORT_DMA is.

Thanks,
Alex

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: UART DMA Defines
« Reply #1 on: May 24, 2018, 03:32:41 PM »
Alex

That piece of code with SERIAL_SUPPORT_DMA_ is from some work with break detection mixed with Rx DMA. It is disabled with the "_" at the end.

In order to test Rx free-running DMA do the following:
1. Enable FREE_RUNNING_RX_DMA_RECEPTION in application.c which will open the driver as required and allow the task to poll the state of the DMA buffer (rather than be scheduled on each byte reception).
2. Make sure that SERIAL_INTERFACE is enabled in config.h (enables global UART support).
3. make sure that SERIAL_SUPPORT_DMA_RX_FREERUN is enabled in app_hw_kinetis.h
4. for 3. you will need to have SERIAL_SUPPORT_DMA and SERIAL_SUPPORT_DMA_RX enabled (general UART rx DMA support)

Note that you may get an error with a variable called Channel - change this to channel if you get it (due to a check-in with a change that hadn't been checked correctly)

This will allow the command line interface on the debug UART to operate with the UART receiver in free-running DMA mode (tx will generally also use DMA).

You can verify that it is operating as expected by pausing the operation with the debugger and typing in some test input. When you let the debugger continue the input will be handled (and echoed), showing that the reception was not lost due to the CPU not being able to respond (and was saved correctly via DMA).

Note that the application task is in polling mode with this option and checking the reception buffer using fnMsgs(). The polling rate is however not critical since the receiver can autonomously put reception to the input buffer (where it waits to be handled) without any CPU intervention.

Regards

Mark



Offline AlexS

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: UART DMA Defines
« Reply #2 on: May 24, 2018, 05:31:08 PM »
Thanks, Mark! It's working fine now.