receiving string (or text file) from PC using UART without DMA and with DMA- KL25z

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

receiving string (or text file) from PC using UART without DMA and with DMA- KL25z

1,681 Views
ofiryaish
Contributor II

Hi,

I'm working on a project which contain a part in which I need to get a string that contains command (or just text) from the PC (working on visual studio environment).

The problem is that once I send a string from the computer such as "turnOnRed", the KL25z is  not receiving all the string (I trying to  keep it  in char array)- sometimes it receiving one letter and sometimes it even get all string  such as "delay

5000"

I using codewarrior, and in order to get the string i'm using the following command 

char temp=uart_getchar (UART0_BASE_PTR); //it's waiting until data is at UART0_data register

temp is going to char array in case it's suitable (very short code).

the command is  in a while function for multi reading.

note that if i send characters one by one it's working fine. 

the problem (as I see it) is that the computer sends the string at once, and it the uart is not suitable for this kind of work, it doesn't have large FIFO buffer or something like that .

what solution can be to such thing?

Moreover, I need to send large text files and DMA should be suitable for it (I think), what configurations are needed for that? and will I face the same problem which I had in the normal use of UART. 

thank you 

Tags (3)
3 Replies

1,343 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ofir,

   Do you have tried this code:

https://www.nxp.com/downloads/en/lab-test-software/KL25_SC.exe 

  This code platinum_freedom project can send the received the UART data back to PC, this is my test result:

pastedImage_2.png

You can find when received the trunOnRed, the KL25 will send it back to PC, you can find all the PC data is received.

You can try it.

Actually, this code is :

    while(1)
    {
        ch = in_char();
        out_char(ch);
    }

It receves one byte data then send it back.

If you want to receve all the PC UART data directly, you also can use the UART interrupt and associated with the IDLE line detect function.

Wish it helps you!

If you still have question about it, please kindly let me know!


Have a great day,
Kerry

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

1,343 Views
ofiryaish
Contributor II

Hi Kerry Zhou,
I was trying to add the project to the code worrier, but failed to run it due to some errors of undeclared commands and things similar to that. can you please add the sources and headers files that are needs to this project.

Moreover, I think you missed understand my problem. I'm receiving string but only very short ones due the fact that the C# program on visual studio is sending all the string at once. I even tried to raise the bound rate of the communication, and it actually worked, but not for long enough string (''turnOnRed'' worked for example).

Does the solution for this must be by separating the string into little blocks on the PC side and sending them ''block by block'' (do you think I should do delay (by timer)  between each block or it will be fine the send it one by one?)

Do you think that using DMA will give a solution for the KL25z side or not?       

thank you

0 Kudos

1,343 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ofir,

    If you receive the string very short ones, I think you can use the UART interrupt code. Just enable the UART receive interrupt, then when the code is received, store it. The code you can use the register mode, just save the code execution time.

Wish it helps you!


Have a great day,
Kerry

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

0 Kudos