2016-08-18 12:37 PM
hello,
i want to know can we transfer data from CAN Bus to DMA memory on board on HAL Library? if yes or no can some one please explain how ?Thanks in advance!!! #hal #hal #can #!stm32-!cubemx-!can-!bug #canbus #cubemx #uart #stm32 #stm322016-08-18 01:17 PM
It would seem readily apparent from the Reference Manual that it can't.
2016-08-18 02:14 PM
Given the short packet size and multiple receive buffers there is little or no benefit in using DMA. The setup time for DMA becomes significant when transfer sizes are so small.
CAN data rarely streams in a nice linear fashion suitable for DMA. Each message can reference a different object, and there are two priority levels for RX which makes any kind of DMA impractical. Streaming packets into one large buffer only means you have to add additional overhead to determine where to route each one, something done just as easily as each one arrives.
How do you handle out of order arrivals? Messages queued for transmit don't arrive in the same order. Higher priority objects take precedence, which means your nice circular DMA buffer needs a software scatter-gather handler to sort out messages. In large part this duplicates what happens in the interrupt handler.
So there is a good reason there's no DMA. You will see the same thing for FS USB, low speed packets processed directly.
Jack Peacock
2016-08-18 02:34 PM
I agree on the pointlessness of the endeavour. You'd waste more time/resources than could be possibly gained.
So there is a good reason there's no DMA. The fact that it is bolted on Third Party IP is also a very strong reason to leave it alone rather than integrate it like a normal peripheral. It is designed to function reasonably autonomously.2016-08-19 05:13 AM
i need to to receive my data from CAN bus, merge the data(2 bytes of data from CAN bus into one Hexa decimal 1 byte) and then transfer it on UART.
That is the reason i asked. i thought to use DMA-to-UART buffer to store. is it possible in this condition?2016-08-19 10:23 AM
It is certainly possible to feed data to the USART via DMA, large buffers would clearly be preferable to reduce overhead.
The description of what you want to do with the CAN data is a bit cryptic. How are you merging the data into a byte? Perhaps you can illustrate with a typical CAN packet, or packets, and then how you expect that data to be presented on the serial console.