Skip to content
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

Completion handling doesn't wait for DMA completion (only for PIO completion) #1

Open
Lak4CYUT opened this issue Mar 25, 2022 · 4 comments

Comments

@Lak4CYUT
Copy link

Hi Brian,
Thanks for your article and sample code, I am studying about PIO and try to create a simple sensor<>LCD project.
After studied your source code, there is a little question about ISR.
Why your capture callback is rely on PIO's ISR but not DMA's ISR? Am I misunderstand something?

@usedbytes
Copy link
Owner

Hi,

I think you're quite right, this is technically a bug.

In an earlier implementation I was waiting for DMA completion but I must have dropped that when I moved over to using the PIO ISR.

In practice, I expect this is very unlikely to be a problem - I'd expect the remaining DMA transactions to complete extremely quickly after the PIO interrupt fires; worst case there's 3 planes, 4 entries in each, so a total of 12 DMA transfers needed to completely drain the FIFOs. That would be 12 cycles assuming no bus contention, and best-case the M0+ interrupt entry latency is 15 cycles, so in all likelihood the ISR won't have even started executing by the time the DMA finishes.

Still, I'll have a closer look at whether this could be a problem, I need to check what could slow the DMA down.

@usedbytes usedbytes changed the title A little question about ISR Completion handling doesn't wait for DMA completion (only for PIO completion) Mar 25, 2022
@Lak4CYUT
Copy link
Author

Thanks for your kind reply, it is very detailed and helpful to me.

Would you mind giving me some technical advice?
I plan to create a 1) PIO continuously receives data(rely on VSync/HSync) and a 2) DMA ISR loop(callback?) to monitor/fetch FIFO data, send to LCD via I2C/SPI line by line.
Ideally, there are 2 isolated components that execute their own jobs independently.
Do you think that plan works?

@usedbytes
Copy link
Owner

Hi sorry, forgot about this.
Are you talking about feeding the camera output directly to a display?

That sounds OK, it will depend on whether your display can directly take the pixel data or if it needs some conversion or some additional commands at the start of every line for example.

If you have enough RAM, I think it would be easier to write the camera data to memory first, then write that to the display. Then you have more control over the timing and you'd be able to add stuff to the image like if you wanted to add text or a reticule or something.

Sounds interesting anyway!

@Lak4CYUT
Copy link
Author

Lak4CYUT commented Apr 1, 2022

My company develops a lot low resolution image sensors, so I can find a grayscale (mono) sensor for my project :).
I guess the memory (240k) is not become the problem. XD

Because I want to separate PIO & DMA (two parts work independently),now I am thinking about how to let MCU know there is a new frame coming (to start the DMA job). It seems IRQ is only way.

Anyway, thanks for your kindly support and chat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants