AnsweredAssumed Answered

UART using DMA on FRDM-KL25Z128

Question asked by Yadhukrishnan V M on Jan 7, 2017
Latest reply on Jan 10, 2017 by Yadhukrishnan V M


I have completed uart transmission on FRDM-KL25Z  using DMAChannel_LDD and Init_UART components in code warrier.I am using UART0 of the kl25z, the pins are setup as PTA1 and PTA2 which are connect to OpenSDA port. I got the correct output using the below code.




/* Including needed modules to compile this module/procedure */

#include "Cpu.h"
#include "Events.h"
#include "DMACH1.h"
#include "DMA1.h"
#include "UART0.h"
/* Including shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"

void StartApp(void);

uint8_t dmaSrc[]="\fHello Yadu Bro\r\n ";/* array used as source for DMA to set uart */


void StartApp(void) {

DMA_PDD_SetSourceAddress(DMA_BASE_PTR, DMA_PDD_CHANNEL_0, (uint32_t)&dmaSrc[0]); /* set destination address */
DMA_PDD_SetSourceAddressModulo(DMA_BASE_PTR, DMA_PDD_CHANNEL_0, DMA_PDD_CIRCULAR_BUFFER_16_BYTES); /* circular buffer with 32 bytes */
DMA_PDD_EnableSourceAddressIncrement(DMA_BASE_PTR, DMA_PDD_CHANNEL_0, PDD_ENABLE); /* source address will be incremented by transfer size */
DMA_PDD_SetSourceDataTransferSize(DMA_BASE_PTR, DMA_PDD_CHANNEL_0, DMA_PDD_8_BIT); /* Transfer from source size is 16bit */

DMA_PDD_SetDestinationAddress(DMA_BASE_PTR, DMA_PDD_CHANNEL_0, (uint32_t)&UART0_D); /* set destination address */
DMA_PDD_SetDestinationAddressModulo(DMA_BASE_PTR, DMA_PDD_CHANNEL_0, DMA_PDD_CIRCULAR_BUFFER_DISABLED); /* no circular buffer */
DMA_PDD_EnableDestinationAddressIncrement(DMA_BASE_PTR, DMA_PDD_CHANNEL_0, PDD_DISABLE); /* no auto-increment for destination address */
DMA_PDD_SetDestinationDataTransferSize(DMA_BASE_PTR, DMA_PDD_CHANNEL_0, DMA_PDD_8_BIT); /* Transfer to destination size is 16bit */

DMA_PDD_SetByteCount(DMA_BASE_PTR, DMA_PDD_CHANNEL_0, sizeof(dmaSrc)); /* set number of bytes to transfer */
DMA_PDD_EnableTransferCompleteInterrupt(DMA_BASE_PTR, DMA_PDD_CHANNEL_0, PDD_ENABLE); /* request interrupt at the end of the DMA transfer to set new byte count */
DMA_PDD_EnablePeripheralRequest(DMA_BASE_PTR, DMA_PDD_CHANNEL_0, PDD_ENABLE); /* enable request from peripheral */

Cpu_EnableInt(); /* enable interrupts */

for(;;) {
/* just wait here, DMA will do the work.... */

int main(void)









Now I want to receive the data through the receiver when I type letters in keyboard. What changes I have to made on above code to receive the characters. Please help!