The UART of the KM34

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

The UART of the KM34

2,445 Views
小勇邹
Contributor II

Can the UART of KM34 work in the DMA mode? If yes, is there any example?

Labels (1)
0 Kudos
Reply
8 Replies

1,761 Views
小勇邹
Contributor II

Hi,

I have used the example "C:\Freescale\SDK_2.0_TWR-KM34Z75M\boards\twrkm34z75m\driver_examples\spi\dma_b2b_transfer\master\iar\spi_dma_b2b_transfer_master.eww" .But the communication result is not successful.What is the reason?

0 Kudos
Reply

1,761 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi

Would you please tell us what kind of error you have meet?

I have only one TWR-KM34Z75M, so I don't have another spi instance on othereboard as slave.

readme dma_b2b_transfer.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,761 Views
小勇邹
Contributor II

Hi,

Thank you for your help.The error happens because I have not connected the slave.

Now I have another question.

I transplant the DMA source code to my old project.

There is an error  "No valid CPU defined!" in the file fsl_device_registers.h after the compiling in the my old IAR project.

It happens because I have not define the CPU_MKM34Z256VLL7 and CPU_MKM34Z256VLQ7.

I cannot find where to define CPU_MKM34Z256VLL7 and CPU_MKM34Z256VLQ7 in the example.

Can you tell me where to define the CPU_MKM34Z256VLL7 and CPU_MKM34Z256VLQ7?

0 Kudos
Reply

1,761 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

You can find it in the Defined symbols:

define CPU_MKM34Z256VLQ7.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,761 Views
小勇邹
Contributor II

Hi,

Thank you  very much.

Now I have another question.

How to set the priority level of the “DMA channel transfer complete interrupt”? I cannot find it in the example.

0 Kudos
Reply

1,761 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Please use the API NVIC_SetPriority ( IRQn, priority ).

NVIC_SetPriority.png

"Interrupt_handling_KSDK.pdf" can be download from Interrupt handling with KSDK and Kinetis Design Studio.

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,761 Views
小勇邹
Contributor II

Hi,

Thank you very much.

Now I have another question.

I let the DMA stay in the receiving mode to receive the data from the master.

The steps to let the bug reappear:

1.Start the receiving:

   {

    uint8_t rx0_buf[10],

    uart_transfer_t receiveXfer;

    receiveXfer.data = &rx0_buf[0];

    receiveXfer.dataSize = 10;   

      UART_TransferReceiveDMA(DEMO_UART, &g_uartDmaHandle, &receiveXfer);

 }

 

2.Restart the receiving again after receiving a frame

 

void UART_UserCallback(UART_Type *base, uart_dma_handle_t *handle, status_t status, void *userData)

{

        if (kStatus_UART_RxIdle == status)

        {

uint8_t rx0_buf[10],

    uart_transfer_t receiveXfer;

    receiveXfer.data = &rx0_buf[0];

    receiveXfer.dataSize = 10;  

     UART_TransferReceiveDMA(DEMO_UART, &g_uartDmaHandle, &receiveXfer);

           

        }

 

}

 

3.If sending 10 bytes in the master 10 times in 1s period, the receiving is OK every time.

Remark: The frame in the master---AA AA AA 8C 01 80 FB 02 00 01

pastedImage_1.png

4.But if sending 20 bytes in the master 10 times in 1s period, there is an error for the receiving. The DMA interrupt does not happen anymore after sending 10 times in the master. It seems that the DMA communication is dead.

Remark: The frame in the master----AA AA AA 8C 01 80 FB 02 00 01 12 12 12 12 12 12 12 12 12 12

 

How to restore the DMA communication in such case? Thank you.

0 Kudos
Reply

1,761 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi

Yes. The UART of KM34 can work in the DMA mode.

Please check the chapter "25.1.1 DMA Request Sources" and "45.8 DMA operation" in KM34P144M75SF0RM.

DMA request sources UART.png

DMA UART.png

You can refer the example "dma_transfer" in KINETIS-SDK.

dma_transfer in SDK_2.0_TWR-KM34Z75M.png

Please search KM34 then select TWR-KM34Z75M and download SDK_2.0_TWR-KM34Z75M.

Select KM34.png

download KM34.png
You can getting start with KSDK reading "How to start with KSDK".

 

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply