-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Serial DMA for variable sized transfers #325
Comments
Some ideas
|
I was actually able to implement variable sized transfers in my RTIC application now and it seems to work well :-) I am thinking of preparing an minimal example where variable sized strings can be sent to the device and will be echoed back (or even processed, for example to switch on LEDs for certain cmd strings). I think this might be useful to other people, especially because it shows how to use DMA in combination with |
Hello,
I think this question might also be suited in a forum post. I am using a STM32F3-Disco in my current project so I thought that I can also ask this here.
I am currently planning on how to perform variably sized transfers using DMA + IRQ + RTIC. According to some forum posts, this is definitely possible using the IDLE line or the Receiver Timeout IRQ by the USART peripheral. More specifically, I wanted to have one RTIC task which uses DMA to send all TX data, and one RTIC task to receive variable sized RX packets, which are only limited in their maximum size.
Unfortunately, I have not really found an example for this in Rust yet and I only have experience with variable sized transfers using a combination of FIFO + IRQ on a smaller Cortex-M0 based system. Most of the DMA based API I have found uses the
read_exact
API which uses a fixed buffer size.I've looked around and experimented myself a little bit. I have found this code snippet: https://github.com/kalkyl/f303-rtic/blob/main/src/bin/serial.rs , which goes into the direction of what I require.
Some thoughts I had:
Now, from what I have see from the STM32F3 HAL docs, this will not be straightforward.
One problem is that I am forced to split the serial struct for DMA transfers, as the transfer struct takes ownership of the RX or TX part. This definitely makes sense, but I need the serial struct to check IRQ events . I could retrieve those using the join method, but that will never be possible because a DMA transfer for RX will practically be active permanently, and thus the RX part will always be unavailable, being cached in some transfer struct unavailable to the TX task. What is the common approach when facing a problem like that? One idea I had was to adapt the split function to return the USART peripheral so I can use it at my own peril for things like this.
Maybe someone has a better idea how to do this? Maybe there is also some other aspect I am forgetting here.. I checked the available interrupts of the STM32F303 again. I guess the core problem is that the interrupt register is used both for RX and TX, although some of the events can be checked independently for RX and TX..
The text was updated successfully, but these errors were encountered: