UART with DMA Receiving example

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: barthess, RoccoMarco

naum_18
Posts: 2
Joined: Fri Mar 18, 2016 9:32 am

UART with DMA Receiving example

Postby naum_18 » Mon Feb 03, 2020 4:25 pm

Hello, i am new in ChibiOS. Is there any examples of data receiving through UART with DMA? It's pretty hard to understand how uart receiving works.
where received data counter located?
this is the algorithm of my actions:
1) configuring uart (example style)
2) in main in "while" called
uartStartReceive();
3)then
osDelay(700);
I see the data in debug but i do not know where is data counter. I will be grateful for the link to an example or advice.
Thank you!
Best wishes!

User avatar
Giovanni
Site Admin
Posts: 13125
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 769 times
Been thanked: 653 times
Contact:

Re: UART with DMA Receiving example

Postby Giovanni » Mon Feb 03, 2020 7:12 pm

Hi,

The uartStartXXXX() functions are asynchronous, the end of the operation is signaled by a callback which can be not exactly easy for a first approach.

Note that the driver also has functions without "Start" in the name, those are synchronous, the function returns when the operation is done, you may try those initially if you don't need the complexity associated to callbacks. Try uartReceive(), uartReceiveTimeout(), uartSend() etc for example.

Giovanni

naum_18
Posts: 2
Joined: Fri Mar 18, 2016 9:32 am

Re: UART with DMA Receiving example

Postby naum_18 » Tue Feb 04, 2020 9:11 am

Thanks for advice, Giovanni. When I tried synchronous function, the program went into rxchar callback. When I tried asynchronous function, the program did not go into rxend callback. Same time program went into txend2 callback when i tried to send data through asynchronous function.
I can see it in debug with breakpoints and leds. Also program never went into rxerr callback. Looks like program never went into rxend callback but data still receiving. I have no ideas about it.
I am using UARTD1 and my UARTConfig looks like:
static UARTConfig uart_cfg_1 = {
txend1,
txend2,
rxend,
rxchar,
rxerr,
115200,
0,
USART_CR2_LINEN | USART_CR2_STOP1_BITS,
0
};

Thank you!
Best wishes!

User avatar
Giovanni
Site Admin
Posts: 13125
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 769 times
Been thanked: 653 times
Contact:

Re: UART with DMA Receiving example

Postby Giovanni » Tue Feb 04, 2020 9:16 am

Hi,

Synchronous functions only handle rxchar and rxerr callbacks. Being synchronous there is no need for the other callbacks, just put those to NULL.

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 7 guests