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个帖子/ 0新
Last post
adam.stroz
Offline
Last seen:1 week 2 days ago
加入:2020-05-22 07:54
Sending a lot of data by UART (DMA using)

Hello,

我对使用DMA(“UART_OP_DMA”)通过UART发送大量数据的问题。我试图发送例如450字节的数据(char选项卡[450])。我在终端上的数据,但只有约400个符号是正确的。当我使用“uart_op_blocking”时,一切都是正确的。

Abowe part of my test code:

#define size 500 char选项卡[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:21 hours 58 min ago
工作人员
加入:2018-02-08 11:03
Hi adam.stroz,

Hi adam.stroz,

我建议首先检查SDK的6.0.14.1114 \ projects \ target_apps \ peripheral_examples \ uart。在我身边,我能够使用UART_SEND_DMA_EXAMPLE()打印超过500个字节的字节。为此,请检查您是否具有相同的配置并使用表替换output_string。

Thanks, PM_Dialog

adam.stroz
Offline
Last seen:1 week 2 days 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):

(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:21 hours 58 min ago
工作人员
加入:2018-02-08 11:03
Hi adam.stroz,

Hi adam.stroz,

你能澄清什么是不起作用的吗?

Thanks, PM_Dialog

adam.stroz
Offline
Last seen:1 week 2 days 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.

我不知道为什么我的程序向UART发送一些垃圾。

PM_Dialog
Offline
Last seen:21 hours 58 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 2 days ago
加入:2020-05-22 07:54
Hello,

Hello,

我不使用任何睡眠模式。

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

当我以调试模式运行时,指令后的程序UART_SEND.continues work normally.

If it matters, i callUART_SEND.func inuser_on_connection func.

PM_Dialog
Offline
Last seen:21 hours 58 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 2 days 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:21 hours 58 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 2 days 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:21 hours 58 min ago
工作人员
加入:2018-02-08 11:03
Hi adam.stroz,

Hi adam.stroz,

我的道歉 - 忘了在我以前的评论中附加代码段。我已经使用UART2块在empty_peripheral_template中进行了测试。数据在连接回调中打印。

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 2 days 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:

而(!Uart_send_finished);

(我不想等到发送完成)。当我从代码中删除此部件时,发生相同的问题(垃圾符号)。

您能删除这部分代码和测试吗?

adam.stroz
Offline
Last seen:1 week 2 days 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:21 hours 58 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