Тёмный

Raspberry Pi Pico PIO - Ep. 8 - Introduction to DMA 

Life with David
Подписаться 9 тыс.
Просмотров 19 тыс.
50% 1

Join David as he explores Direct Memory Access (DMA) for the RP2040. Included are examples of how DMA works with PIO and IRQ.
00:00 - Introduction
00:44 - DMA Structure
02:57 - Simple DMA-PWM Fade LED Example
03:39 - Initialize PWM
05:09 - Configure DMA
08:10 - Rune the DMA-PWM Example
08:41 - DMA-PIO-IRQ LED Example
09:31 - PIO Program
12:01 - Main C program
12:34 - Interrupt Handler
14:13 - Configure PIO
14:43 - Configure DMA
16:30 - Run the DMA-PIO-IRQ Example
16:44 - Closing
Links:
Files for this episode:
github.com/LifeWithDavid/Rasp...
RP204 Datasheet:
datasheets.raspberrypi.com/rp...
Raspberry Pi Pico C/C++ SDK:
datasheets.raspberrypi.org/pi...
Craig Chadwick's DMA BLOG:
gregchadwick.co.uk/blog/playi...
Music:
(Pinnacle 19.5 royalty-free music):
Pulsing Dance
House Fever
Reaction Time
City Night Groove

Наука

Опубликовано:

 

5 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 37   
@Eric_Moderbacher
@Eric_Moderbacher 2 года назад
I have really been enjoying all of the videos in this series. The pico seems like a game changer for inexpensive hobby electronics, thanks for helping to make it feel even more approachable!
@LifewithDavid1
@LifewithDavid1 2 года назад
Glad you like them! Thanks for watching!
@benpapworth
@benpapworth 2 года назад
This series has been a great introduction to PIO and the capabilities of the pico. Compared to bit-banging, this seems so much more efficient, but also much more accessible! It’s great to see the instant feedback of Python, and then the performance of C. The Raspberry Pi folks should link to your channel! I have one of the Pimoroni PicoSystem game pads - now reading through the C code in their SDK, I’m understanding how they are driving the LCD, and makes me feel confident about writing my own driver code. Keep up the good work!
@LifewithDavid1
@LifewithDavid1 2 года назад
Thank you very much! I'm going down the DMA/PWM rabbit hole right now. We'll see where that leads.
@rtnashokverma3486
@rtnashokverma3486 2 года назад
Hi David. I just saw your video on your surgery. I very much hope you are doing good & would be back soon with very useful videos. With best wishes. Ashok
@LifewithDavid1
@LifewithDavid1 2 года назад
Thank you for your kind words and thoughts. I've been trying a couple pair of glasses and I think I'm getting used to the vision change. Close work is still a challenge; but getting better. I'll be going to AirVenture next week; maybe a couple of videos from there. Then I hope to get back to some RasPi Pico videos. Thanks for watching!
@PeetHobby
@PeetHobby Год назад
Thanks mate, I just looked into the pico's DMA myself so this was a perfect video for me. Thumbs up! 😁 DMA is great, if your micro has DMA use it, DMA makes moving data around much easier.
@LifewithDavid1
@LifewithDavid1 Год назад
You're welcome. My VGA and AWG videos also have a lot of DMA content.
@mmarkdev
@mmarkdev 4 месяца назад
thank you for your video. a lot of good knowledge, presented in a simple way🎉
@LifewithDavid1
@LifewithDavid1 4 месяца назад
Glad it was helpful! Thanks for watching.
@temp8420
@temp8420 11 месяцев назад
Great video thanks
@LifewithDavid1
@LifewithDavid1 11 месяцев назад
Glad you enjoyed it. Thanks for watching!
@MordecaiV
@MordecaiV 2 года назад
When the Pi Pico first came out, I mostly wrote it off as uninteresting. I thought then that the "programmable input/output" was just choosing what pins to use for the various built in hardware interfaces. Recently started pursing a project and found out the truth! watching all your PIO vids multiple times now to get up to speed.
@LifewithDavid1
@LifewithDavid1 2 года назад
Glad it was helpful. Thanks for watching!
@davidrankin8590
@davidrankin8590 Год назад
This video cracked me up -- but it was really good. Taking the time to go through the datasheet and show where the information can be gleaned is a vital step that all too often is ignored. I just picked up a Pico and am having quite a bit of fun. I ended up here because I had written a RTC initialization from the PC to the Pico over the uart and was hoping to speed the process up a bit. Essentially the PC sends a string to the Pico via PuTTY or redirected from an xterm to ttyACM0 (or using minicom). The string is formatted as "+++2022 09 09 5 20 52 58", the "+++" used for an acknowledge that the RTC initialization data comes next. My only concern looking at DMA is with 24 bytes total transfer, DMA may not help that much over a character-by-character read. But with your help -- I now have the tools to find out. Much appreciated.
@LifewithDavid1
@LifewithDavid1 Год назад
Thanks for watching. DMA works best when you have to send a ton of data quickly; without slowing down for the processor. I have several more videos where I use DMA and PIO to move a lot of data; both video and an AWG. Have fun!
@robertboyer5926
@robertboyer5926 2 года назад
I stumbled across this while looking for some real world examples of PIO usage for a project I am working on (also new to the pico). Specifically looking for example code that implements a multi wire protocol and specific timing inside the scant instructions inside of one PIO, if that can be done or people load multiple programs inside the same PIO and how timing dependencies are handled in that case, etc... In any case very good job explaining the PIO, PWM, and DMA for everyone working with this new and very different chip. I know you issued a disclaimer regarding your knowledge of C and that it's not the topic of this video specifically, I don't know if you left it out on purpose or possibly didn't realize that the code you are using has a nuance that people should probably understand when generalizing this to other purposes regarding DMA and specifically PWM (there are other situations that are similar beyond PWM that depend on the specific architecture of the component wiring and registers as well) The code above ONLY works if and only if the GPIO pin happens to fall on PWM channel B of a given slice. By chance the built in LED on GPIO 25 does but this is atypical for most other examples where the Default output pin is chosen to be on A specifically. Here's why... 1. You declare the fade vector as uint32 and the transfer width of the DMA as 32bits. 2. When using DMA to the counter compare PWM register as 32bits what happens is that the upper 16bits are for the B channel of the slice and the lower 16bits are for the A channel. 3. In your comments you mention a "gamma adjustment" which I assume you mean the square? but some may assume that you mean the
@LifewithDavid1
@LifewithDavid1 2 года назад
Thank you very much for your comments; they are right on! I did learn a lot from this video, and I got into DMA and PWM in much more detail in the next video, that's where I realized the difference between PWM channel "A" and "B". The gamma reference was from the sample program I was using, I believe it refers to the relative brightness of the LED. Thanks for watching, hopefully the next few videos will be helpful.
@robertboyer5926
@robertboyer5926 2 года назад
@@LifewithDavid1 Ps I meant GPIO 26 for the LED I think, don't have the reference sheet in front of me at the moment but the assertion is correct. I did find it strange that the SDK has a lot of convenience functions but some of them offer a strange mix of convenience combined with raw register writes like the one discussed above. I guess learning any new hardware is tricky. I'm still at the very beginning with PIO where I am constantly asking my self questions "I wonder if this will work" for things that aren't explicit in the documentation. I agree the docs are extremely good relative to a lot of hardware I've used but there are still some ares that are vague. Like pindirs and their specific semantics with side set etc.
@mohahary7410
@mohahary7410 Месяц назад
Thank you David. We can use for example raspberry pico for object detection in real time. For example we use PIO to transfer data between camera and one core of raspberry pico pico and the other core well be used to run machine learning Model. Is that feasible??
@LifewithDavid1
@LifewithDavid1 Месяц назад
That's very feasible as long as the Pico has enough computing power and memory for your application. In fact, you could use PIO with DMA to transfer the data from the camera into memory without using any core resources. Then you would have both cores available for machine learning. Sounds interesting. Good luck!
@RealDevastatia
@RealDevastatia 11 месяцев назад
What's that 8-bit hot rod in the wooden case behind your monitor then?
@LifewithDavid1
@LifewithDavid1 11 месяцев назад
That's my 6502 multi purpose computer built 35 years ago. I feature it in several videos, including this one: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-BcqRvHkn-EA.html I also do some high speed paper tape emulation with it in later videos using the Pico and (shudder) MicroPython. This is where I first started using PIO. This computer was the 3rd one I built; there is another video on my earlier computer, as well as Tiny Basic. Thanks for watching!
@user-qh5br9jl9g
@user-qh5br9jl9g 5 месяцев назад
How about dma into a separate peripheral? Like a trinket which has a 264 on chunk also. Maybe leave it bare metal? Thoughts? Or maybe do that to an soc, like a raspberry pi?
@RealDevastatia
@RealDevastatia 11 месяцев назад
So glad to see you using C and not that hideous Python.
@kippie80
@kippie80 2 года назад
The dma_handler() function appears to be missing a close patenthisis? I don't mean to be pedantic but well, computers just are that yes/no?
@LifewithDavid1
@LifewithDavid1 2 года назад
I'll have to check it out. Sometimes transferring the program from the working version to github leads to errors. Thanks!
@kippie80
@kippie80 2 года назад
@@LifewithDavid1 Ah, yes, the error is in the github. But some edits needed regardless as I see you've put it all in one file. No surprise you'd taken to Python. Having just missed the day's of being taught Fortran in University (by one year, and still used it in projects due to math libraries), I've always resisted Python myself. But if you are used to Fortran, Python is a much better version of that. But NOPE, I'd just tried a Python project recently and it had a format validation tool.. Nope, no thanks! Rust is much more my thing if not C/C++. Anyhow, the ommission is a very Python-esque error. Cheers!
@robertboyer5926
@robertboyer5926 2 года назад
@@kippie80 being a curmudgeon myself I've found very little value in most new languages (new as in newer than any sort of macro assembler of which even in the late 70's many assemblers were very powerful in terms of "higher level constructs" and even data structures, newer than ESPOL (aka a systems level ALGOL for Burroughs large systems) and PL/S) I accidentally took a "temporary job" writing the firmware for some computer company not to be named and stumbled upon C which is the last new language I've found much value in, which is VERY valuable for many reasons) Sure I've had to use a dozen new languages in the age of the internet, not many actually had anything new, just rehashed bad ideas for the most part. Their attraction isn't the language itself but merely the idiotic amount of options and ease of sucking in massive amounts of other people's code without care written 10 seconds ago rather than the language itself. Having said that... within the last 2 years I've consolidated ALL of my dev work across the entire stack from micro controller to web crap to 2 language thank god. C(and C++ with a lot of restraint in terms of use of language features god what a mess unless you ignore the bad ideas) and believe it or not... Go which is sort of like "really easy C" with a crazy easy build/package management system. I only responded to this as you mention Rust... I have very mixed feelings about Rust... it's one of those things I WANT to love but having been trying to love it for a few years now I just can't and from a practical stand point I really think the team seems to making mistakes in terms of language complexity and features. It is not nearly as programmer friendly as C and at the end of the day relies on what C does best for a lot of its target scope. I am not making a final judgement call yet but it's too volatile for me to buy in and hasn't yielded much actual benefit to me when using it side by side on various real life stuff to get comfortable with it over the last few years... I think the biggest thing I like about it happens to be: 1. Rustup 2. Cargo I wish the C/C++ ecosystem could really consolidate around a similar tool chain/package management system other than that I've been fairly happy with C since the mid 80's. "Safe" programming practices have been around for a very very long time. Just my 2c
@LifewithDavid1
@LifewithDavid1 2 года назад
I agree. My experience started with FORTRAN and I was pretty good with it. That lead into Basic and several other languages of the mid to late 70's. However, those languages tend to warp the minds of those that use them such that I have a difficult time "thinking" in terms of "object oriented" programming language. Programming is not part of a electric power utility project manager's job; so I only programmed for fun. Now that I'm retired; I'm trying to make up for lost time; with mind numbing results. Thanks for watching!
@adeeperbluegreen
@adeeperbluegreen Год назад
Not sure why there is music popping up in the brief silence between statements. Makes it very hard to concentrate on the material.
@LifewithDavid1
@LifewithDavid1 Год назад
That's a good point. I like a little background music; and I am trying to get the audio ducking settings right. I hope it's better in my more recent videos. I'm using Pinnacle Studio 25 and it's a bit of a challenge.
@adeeperbluegreen
@adeeperbluegreen Год назад
@@LifewithDavid1 I would not use filler music in any video I wanted people to retain information from. Music is meant to invoke emotions and tends to distract from informational content.
@tomstewart1444
@tomstewart1444 Год назад
Personally I like the music popping up. I instinctively pause the video to take in what David just said, re-read the code and relate it to what went before. Thanks David!
@alinaqirizvi1441
@alinaqirizvi1441 Год назад
@@adeeperbluegreen I think it would sound a bit bland without it though
@lfarge
@lfarge 2 года назад
Very nice content. Sadly blurry from mid video...which makes the listener loose focus
@LifewithDavid1
@LifewithDavid1 2 года назад
Sorry to hear that. I checked and the video looked clear on my computer. Unfortunately, during times of constricted bandwidth, RU-vid viewers may experience lower quality playback. Maybe try again; off peak. Thanks for watching!
Далее
Symmetrical face⁉️🤔 #beauty
00:15
Просмотров 3,6 млн
ПОМОГЛА НАЗЫВАЕТСЯ😂
00:20
Просмотров 2 млн
Raspberry Pi Pico LCD Projects
17:25
Просмотров 107 тыс.
WAY faster than a Raspberry Pi-but is it enough?
17:26
Просмотров 661 тыс.
Hacking my garage door with the Raspberry Pi Pico W
11:50
How to Soldering wire in Factory ?
0:10
Просмотров 13 млн
📱магазин техники в 2014 vs 2024
0:41
КРУТОЙ ТЕЛЕФОН
0:16
Просмотров 7 млн