Sending a lot of data by UART (DMA using)

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
15 posts / 0 new
Last post
adam.stroz
Offline
Last seen:1 week 23 hours ago
加入:2020-05-22 07:54
Sending a lot of data by UART (DMA using)

Hello,

我有一个小疑问发送很多a by UART using DMA ("UART_OP_DMA"). I tryed to send for example 450 bytes of data (char tab[450]). I recive data on terminal but only about 400 sign is correct. When i use "UART_OP_BLOCKING" everything is correct.

Abowe part of my test code:

#define size 500 char tab[size]; for(uint32_t x=0;x

And results on terminal (before this i've get correct 400 signs "b"):

´üؐü<0><0><0><0>´ü<0><0><0><0><0><0><0><0>“×đ@›ü<0><0><0><0> <0><0><0> <0><0><0><0><0><0><0><0><0><0><0> Ęń

My question is:

What i'm doing wrong ?

Device:
PM_Dialog
Offline
Last seen:6 hours 3 min ago
工作人员
加入:2018-02-08 11:03
Hi adam.stroz,

Hi adam.stroz,

I would recommend first checking the 6.0.14.1114\projects\target_apps\peripheral_examples\uart of the SDK. In my side, I am able to print more than 500 bytes using the uart_send_dma_example(). To do so, please check if you have the same configuration and replace the OUTPUT_STRING with your table.

Thanks, PM_Dialog

adam.stroz
Offline
Last seen:1 week 23 hours ago
加入:2020-05-22 07:54
Hello,

Hello,

I tested your example (with Keil, normally i'am working with smart snippers studio). In your example when i replace OUTPUT_STRING with my table (500 'b' sign) everything is correct (i recive 500 'b' sign on terminal). But my program still don't work. I noticed that, when i insert (only for test purposed):

while(1);

after send instruction, everything is correct (i recive 500 'b' sign on terminal).

Can you give me another instructions ?

PM_Dialog
Offline
Last seen:6 hours 3 min ago
工作人员
加入:2018-02-08 11:03
Hi adam.stroz,

Hi adam.stroz,

Could you please clarify what is doesn’t work?

Thanks, PM_Dialog

adam.stroz
Offline
Last seen:1 week 23 hours ago
加入:2020-05-22 07:54
Hello,

Hello,

Of course, the main problem is that i recive wrong data on terminal (i tryed 2 diffrents terminal). I send 500 sign 'b' but recived only 450 and rest sign are trash. When i stop program after send instructions (by usign while(1) instructions) everything works fine. I work with empty_perpiherial_template from SDK.

I don't know why my program send some trash to uart.

PM_Dialog
Offline
Last seen:6 hours 3 min ago
工作人员
加入:2018-02-08 11:03
Hi adam.stroz,

Hi adam.stroz,

Are you using any of the sleep modes? Can you please run it in debug mode and check if it gets stuck into an assertion etc. ?

Thanks, PM_Dialog

adam.stroz
Offline
Last seen:1 week 23 hours ago
加入:2020-05-22 07:54
Hello,

Hello,

i don't using any sleep modes.

static const sleep_state_t app_default_sleep_mode = ARCH_SLEEP_OFF;
.adv_scenario = DEF_ADV_FOREVER,

when i run it in debug mode, program after instructionuart_sendcontinues work normally.

If it matters, i calluart_sendfunc inuser_on_connection func.

PM_Dialog
Offline
Last seen:6 hours 3 min ago
工作人员
加入:2018-02-08 11:03
Hi adam.stroz,

Hi adam.stroz,

Thanks for the update. So, are you able to print the correct data?

Thanks, PM_Dialog

adam.stroz
Offline
Last seen:1 week 23 hours ago
加入:2020-05-22 07:54
Hello,

Hello,

At this moment no... I don't know what is wrong. Maybe i should try sending on another project (for ex. prox_reporter) ? Can you test for me this simple example (send my example array, with DMA) on your test board ?

PM_Dialog
Offline
Last seen:6 hours 3 min ago
工作人员
加入:2018-02-08 11:03
Hi adam.stroz,

Hi adam.stroz,

Which project of the SDK are you using? I ran it in the UART project from the SDK peripheral examples - 6.0.14.1114\projects\target_apps\peripheral_examples\uart. I used the code snippet below:

Thanks, PM_Dialog

adam.stroz
Offline
Last seen:1 week 23 hours ago
加入:2020-05-22 07:54
I'm using empty_peripheral

I'm using empty_peripheral_template from target_apps\template\empty_peripheral_template. Can you test it for me in this project ?

PM_Dialog
Offline
Last seen:6 hours 3 min ago
工作人员
加入:2018-02-08 11:03
Hi adam.stroz,

Hi adam.stroz,

My apologies – forgot to attach the code snippet in my previous comment. I have tested in the empty_peripheral_template using UART2 block. The data is printed in the connection callback.

CFG_UART_DMA_SUPPORT and CFG_PRINTF macros are also defined in the project.

volatile bool uart_send_finished = false; volatile uint16_t data_sent_cnt = 0; static void uart_send_cb(uint16_t length) { data_sent_cnt = length; uart_send_finished = true; } void uart_send_dma_example(uart_t* uart) { #define size 500 char tab[size]; for(uint32_t x=0;x

Thanks, PM_Dialog

adam.stroz
Offline
Last seen:1 week 23 hours ago
加入:2020-05-22 07:54
Hello,

Hello,
I tested your code and everything is correct. But in my case I want to send data and continue to execute next steps. So I must delete this part of the code:

while (!uart_send_finished);

(I don't want to wait until sending is complete). When i deleted this part from your code, the same problem occurs (trash sign).

Can you delete this part of code and test ?

adam.stroz
Offline
Last seen:1 week 23 hours ago
加入:2020-05-22 07:54
So finally... i solved the

So finally... i solved the problem :) It was enough to declare the array,

char tab[size];

as global. I think, that after the exit function when I declared my array, the array is lost, but pointer that I provided to function uart_send still points to the memory area where the table was. So other instructions in the program could change the data in this memory area. This could result in sending bad data.

PM_Dialog
Offline
Last seen:6 hours 3 min ago
工作人员
加入:2018-02-08 11:03
Hi adam.stroz,

Hi adam.stroz,

Glad that you figured your issue out and thanks for sharing the fix!

Thanks, PM_Dialog