AnsweredAssumed Answered

FRDM-KL25Z: Bare Metal DMA Basics?

Question asked by Mahmoud Sherrah on Apr 8, 2018
Latest reply on May 1, 2018 by Mahmoud Sherrah

Apologies for the long post. I am trying to get my head around DMA on a KL25Z board in bare metal (i.e. without any support from Processor Expert, PDD, uTasker..etc), however there are some basics that I didn't find mentioned anywhere (or maybe I just missed), so any guidance would be greatly appreciated.


Summary of what I'm trying to do: Whenever requested in my software, I want DMA (ex: channel 0) to automatically grab the value in UART0_D (8-bits) and place it in an 8-bit variable in memory (ex: uint8_t receivedByte) (i.e. SAR is UART0_D and DAR is &receivedByte). Note: I don't really care if the UART receive buffer is full or not, I just want to grab whatever value is in UART0_D.


FIRSTLY: DMA Peripheral

1- Is it possible to achieve this without the UART0 peripheral calling for DMA request?

2- Is it possible to achieve this without any interrupts of any kind?

3- If possible, do I have to create an array and pass it to the destination address register "DAR", or a pointer to my uint8_t variable is enough?

4- When I set the DAR register to &receivedByte, GCC gives me a warning of "assignment makes integer from pointer without a cast". Casting &receivedByte to (uint32_t)&receivedByte fixed it but I don't understand why. Isn't &receivedByte already a 32-bit address value?


Here is my proposed configuration of the 4 DMA registers that I think is relevant to my simple application:

1- DMA_SAR0 = (uint32_t)&UART0_D; //UART0_D is 32-bit address of UART0 data register

2- DMA_DAR0 = (uint32_t)&receivedByte;


         BCR: this field should be equal to 1 (since I am trying to transfer only one byte?)

         The rest: don't care?

4- DMA_DCR0:

         ERQ: I believe it should be 0 since I don't want peripheral request as mentioned above.

         SINC and DINC: should be 0 since I don't want SAR or DAR to be incremented after transfer (since I am trying to                                         transfer only one byte)

         SSIZE and DSIZE: should be 01 (i.e. 8-bits since that's what I am transferring (one-byte)).

         SMOD and DMOD: should be 0 (since only 1 byte so no buffer needed)

         The rest: don't care?



1- How can the DMAMUX help me in any of this? Is it essential for any DMA operation? (I don't need periodic triggering      or anything). If it is necessary, how should it be configured to serve my application?


2- Should I use DMAMUX0_CHCFG0 since I want to use channel 0, or is there a catch here?


3- What is meant by SOURCE in DMAMUX0_CHCFG0? Does it mean UART0 in my case? How do I determine the its value?


As you can see, I am just trying to come up with a formal set of steps to run DMA in the most basic mode. Any help would be greatly appreciated.