Once you get the hang of it :-D let us know ... we will bug you for a step by step tutorial that takes us from the pio blink example to writing our own pio stuff. I'm still really puzzled on the raw C helper function % c-sdk
The Raspberry Pi Foundation just lit a fire underneath Arduino. The pico is so packed with features and as such appeals to people that have experience with Espressif's chips while at the same time being more than a quarter the price of an Uno plus being more intuitive. They covered everyone with their hardware, they sure did know what they were doing.
You know that you are comparing Apples and Ataris, don't you? In addition, it won't do any harm if Arduino burns down. That was a joke, of course. Frameworks burn badly, or not at all, when they are mental constructs;) Don't forget: use the right tool for the right job. In some of the comments here you can clearly see how strange a high-speed logic with discrete building blocks is to people. To know about that too can sometimes be an advantage. Or simply have knowledge besides the Arduino, ESP or Raspberry filter-bubble. www.digikey.com/en/products/filter/embedded-microcontrollers/685 ... Fucking 89483 results!
@@dieSpinnt The AVR market is not going to change, I am just fearful of Arduino's position here. You could get a bare bones AVR chip for a comparable price to the pico even after the demise of Arduino no problem. It would only really show how expensive their stuff are and pressure them to act. Whatever happens, knowledge is knowledge.
@@martandrmc Hmmmm, I can't see us both discussing the (insert MCU here) Market. Who buys, calls! In retrospect, my thoughts on your Arduino worries to calm you down: If you have to do something quickly, use a BAD editor (I just don't understand why people pick it up. It's a free decision to use a text editor and not code-completion mumbo jumbo or the other way arround) ... in other words: one that works (!) and you want to try something quickly (with thousands of others strengthening your back with their experience through libraries or support), again: something that works ... proven There is always a niche for this type of hobby or craft work. This niche can be really big, so big that even professionals can use it to quickly try out an idea. I think you shouldn't worry. Especially not because of diversity :)
May I show you something other besides my inabilities of soldering TQFP packages? www.st.com/en/microcontrollers-microprocessors/stm32h747-757.html#overview A powerhouse with camera interface, GPU acceleration and a pin header count that doesn't bring us both to a laughter as the pico. The same free tools and support from an industry leader (let us make jokes, later:)). Raspberry Pi Pico ? I don't see this as god's chip. Don't let you fool from the hype. There are Ten of Thousands out there, if not more ... to choose from. Edit: I cheated a little: for the price of the Pico, you have to give up graphics acceleration but you have up to 160 flexible IO lines .... You can then connect externally via the memory interface, as well as operate quad SPI memory and what works as a PIO there does a DMA controller for normal people. The one described has 4.
@@dieSpinnt In retrospect, comparing the 2 prices is not by any means the full story. There are devboards out there with an STM32 at around the same price as the pico that have better performance than an Uno but still have not gotten to be main-stream yet. Arduino has alot of software behind it that could also work with a Mega if performance is needed. In conclusion i dont think that Arduino is in as much danger as i have thought, but still the pico is backed by a similarly well-known company. It would not be equivalent to compare STMicro the same way. (Also sorry for not checking for a week)
I have been around microcontrollers off and on since the MK3870 at the end of the 1970s. Having this level of IO functionality driven by separate execution units with well thought out instruction sets is just mind-blowing in its possibilities. I know other chip families have had smart, programmable IO systems, but this takes it to a new level. As someone who used only to program in assembler for most of the 1980's, I found that this was a great video that explained the capabilities very well. Thanks. Subscribed.
Me too. I spent five solid years working with 6809,8085,Z80,68K and this video has left my mind reeling with questions like "Yes, but what can/can't you do with it?" I've seen one video of a guy who has recreated the original Transputer boards. I learned Occam for a bit on one of those.
Around 8:25, JMP (X--), the documentation says: JMP X-- and JMP Y-- always decrement scratch register X or Y, respectively. The decrement is not conditional on the current value of the scratch register. The branch is conditioned on the initial value of the register, i.e. before the decrement took place: if the register is initially nonzero, the branch is taken. (RP2040 Datasheet, page 320,321) The emphasis is on ALWAYS so that the decrement is ALWAYS done.
Currently working on a PIO based project, and this video has been a life saver. I'd love see a video that has more examples of how IO mapping works in practice, especially with overlapping pins. Thanks for the great work!
Agreed. as stack says, needs to be a reference first...but would be nice to show a very brief example of an instruction executing (like how the effect on square wave is demonstrated).
I love assembly language for it being so simple yet so complicated. If I'm programming, I always prefer low level, for some reason.... Yet I hate myself afterwards 😂
Coming from Amiga programming background I always find myself reinventing the wheel... :) Love the low level stuff! I haven't watched the whole video yet, but somehow I think that the Amiga co-processor (Copper) has been made to do I/O
This tie up everything together I've read or watched so far about PIO, but never quite get to breaking that threshold of solidifying my understanding of PIO. But the video did it for me. Great job!
I recently got a Pico and a VGA drmo board, and I've spent the last few days getting to know all of the nice peripherals the Pico has. This video is a great overview of the PIO!
Best PIO explanation I've seen so far! Thanks so much. Looking forward to the examples video. I tried to follow the one in hackspace mag but really struggled. I think largely I'm falling down on the buffers and the the shift registers and keep getting lost on what direction things are going relative to what (PIO SM, main cores, or pins/IO). Your diagrams/animations really helped in this video though so thanks for that effort.
Excellent explanation. Thank you for this video! I reduced the speed of the video to 75% though which helped me watching the video in a more relaxed manner 🙂
Meanwhile, I'm watching at 1.5 and not fully processing everything. Oh well, I'm just trying to get the gist of it and I'll look at documentation when I'm actually working with it.
I can't thank you enough for this video, it is very clear, very well structured and very detailed. All other 'tutorials' I've seen pretty much say "PIO is really powerful, you can do amazing stuff. Here's an example of how to flash the on board LED. Work everything else out for yourself".
All this bitbanging is great! Takes me back to channel programming IBM/360. What I need now is a slightly higher level helicopter to understand the pico’s application in an architecture dimension.
Great video. Been reading around this all week without making much progress. Feel like I am starting to understand after watching this video. Well done.
I absolutely love PIO in my chips. It means you can hook up just about anything you want, unconstrained by physical ports or dedicated controllers. It's almost like a tiny FPGA on your chip. My ultimate goal is to get multiple RP2040s running as a cluster using their PIOs.
I’m actually working on clustering a bunch of picos to rebuild Ben Eater’s 8 bit computer (but planning on using 16 bit addresses instead of 4 bit addresses for memory; 65536 bytes instead of only 16 bytes). It kind of silly to build a (slow) cup out of a bunch of processes but some good things are: lots of lights, ability to experiment with cpu architectures quickly (easier than wiring lots of 7400 series chips), and it’s fun and I just want to haha. Python is good enough but I want to using PIO if possible.
Currently looking into implementing i2s audio using the PIO sm's. It's easy enough to imagine "how to do it" in my head. But I have a hard time grasping "the right way". Been watching videos and read up on the documentation. Some stuff confuses me, some makes sense. This video was helpful, although I did miss some examples for some of the instructions and the whole concept of mapping certain pins to PINS are still a bit confusing to me. I'm a visual guy, so I definitely got more from the first part of the video with the visual aids. Great video nonetheless. :) Thanks. EDIT: Btw, one thing I am having a very hard time with, is trying to connect my data in my C / C++ code with whatever the sm reads / works on. That whole IRQ, DMA, FIFO, ISR, OSR situation makes my head explode. :D It's probably simpler than it seems. I just need to slowly work my way into it.
Nice to have this video! This helps me to realize my project. But I don't understand the state machine, because from the UML perspective this is not really a state machine. A state machine must have an entry point and transitions between states, including conditions. The exit state is optional.
Not sure where you're getting that definition. If it's from UML, then they've redefined the term. A state machine doesn't need an exit point. And it certainly doesn't need transitions defined between every state (if that's what you meant there). I've built many no-exit state machines, and almost none with all possible transitions allowed.
@@mr.unbekannt2163 I'm not sure what you're expecting me to get from that page. Are you claiming something in it contradicts me? Or are you claiming that the UML definition does require all possible transitions to be allowed? (In which case as I said they have redefined the term, and inappropriately, I might add.)
I literally never seen a raspberry pie nor even I am a hardware guy still understood everything in this video Awesome work! Gonna watch your all hardware videos!!!
If this post wasn't so 'old', I could have swear it is 100% machine (AI) generated! The speed, rhythm, regularity of reading a text is definitely a robot's voice, no doubt in my mind. Anyways, a good presentation, although a bit superficial.
This looks like the perfect uC to implement some very serious bus sniffers like I2C or SPI. BusPirate has proven to be too slow and unreliable for this, FPGAs as a bit too unapproachable for most.
Thanks - I have been waiting for someone to make this video - you got my sub! I modified the ws2812 RGB example in the python code to work with sk6812 RGBW leds, and it was really hard to find any good examples of exactly what the PIO assembly instructions were doing. And even less info on what the python calls to that code was doing. I hope you will cover this in your future videos. Thanks for all your work.
Quite a bit like the lighting control 'engines' that in the LP5523 LED controller (ca.2006), but maybe without the engine priorities(?), although the pin mux idea is similar. this allows for some pretty fast real-time functionality, without needing cpu intervention, and with a LOT of flexibility. (BTW, if you do need an LED controller that doesn't need you to constantly execute code to do complex LED functions, the LP5523 was designed to offload the cpu, and allow LED functionality when the cpu is in deep sleep, even has an "interrupt" input/output to respond to, or initiate, other hardware functionality.)
Crazy level of presentation my dude! Also, PIOs were the thing that made me interested in the Pico - I'm not even an embedded developer. However, with the Shift Register and its capabilities alone the possibilities are crazy ♥
I love your channel so much and I really want to learn how to use ghidra, I really hope you’ll make more learning videos because I love this field and you can teach concepts and methods really well in my opinion, keep it up please, every video from you is a blast!
Oooo, this is very interesting! Could be cool to use the pio to hook up some picos together, honestly now I am super excited to get my hands on a batch;
Hi, I think there is another errata to be written: at 7:37 and 14:04 you explain, that "set pins, 1" turns an output ON, whereas at 9:01 you explain it as turning it OFF. Or did I misunderstand something here? Thanks for the great video - that was well-paced with dense information!
extremely helpful!! i had to play @ 3/4speed because i am from southern US and i listen as slowly as i speak)) i have posted question on rpi-forum about feasibility of pio-state-machines to implement canbus (would need external differential drivers), but sadly no answers. Please reply with opinion if you are familiar with canbus. many thanks for well done vid.
Thanks for this PIO introduction! I now understand what I read in the datasheet ;o) I have a question: as IN and OUT pins groups can overlap, how are common pins handled? Do they automatically change direction depending if they are shifted in or shifted out? I'm asking because I would like to interface the Pico with a Z80 bus, so IN and OUT should point to the same pins...
Very good but very fast in the discussion. Have to rewind and listen a few times to digest the topics. 8:59 example for JMP is documented in reverse? First the output will be OFF and then ON for 2 cycles? Please confirm.
Yeah, I am only just learning about this, but it does seem logically to be a mis-speak in the video. It seems like the pin would be ON for the cycle the JMP instruction takes (and I don't know enough to know if it would be considered to be ON during the instruction cycle it is set ON, or ON during the instruction cycle it is set OFF, but either way, that is two cycles).
I was surprised to see Pi make this product. What, no linux? I'm in. It reminds me of bit slice programming on the AM2900, or the TPU on the 68332, or Motorola DSCs, or even EPROM based state machines. Now I just gotta think up an application.
I just stumbled upon this and am blown away by this feature. I wanted something like this in the past and was considering programmable logic. Does anyone know which other processors have this feature? Maybe the raspberry Pi computers?
Great video. I would love to have this as a document. I’ll run through this slowly and make a lot of notes. It’s very useful. I’d love to know where you got the data from .
This is actually what i have been waiting for, if i understand it correctly. Thanks for this video! Do i get it right that i can read 8 bit in parallel by only one state machine and write it into memory via dma while data is being transferred via wlan from memory, and all this runs concurrently?
12:03 Sorry, but you've got IRQ WAIT the wrong way around. You said "IRQ WAIT waits for it to be clear before setting it". No: IRQ WAIT immediately sets the IRQ but then waits for the IRQ to be cleared again.
I'd like to confirm this should be added to the errata, qv. C SDK #3.4.9.3 : "irq wait Means set the IRQ and wait for it to be cleared before proceeding"
8:28 The Motorola 68000 family had an unusual decrement-and-branch instruction: instead of decrementing and branching until the count reached zero, in which case it would stop branching and fall through (existing the loop), it would decrement to -1 before exiting. This let you deal easily with the case where the loop count was initially zero, in which case you want to just jump over the loop completely. E.g. move.w #count, d0 bra loop_end top_of_loop: .... body of loop ... loop_end: dbra d0, top_of_loop
So had the Z80: 'djnz address', which stands for Decrement and Jump if Not Zero, where register b (8 bit) was the one being decremented. But these very rare and useful instructions (for creating loops) have not much to do with this discussion about PIO, which are far more complex and programmable!
16:33 Those are just labels that don’t have any special meaning to the assembler. The CPU program then has to set the values of these labels into the relevant PIO registers to enable wrapping.
I'm going to want to make a specialized one wire serial adapter with this thing one day. Edit: Is there a simulator for this? I don't have the hardware to debug the input and output of one of these, would love to be able to provide some basic pin states over time and be able to plot what it does over time.
Search for "Signal/Noise Ratio". One Wire ... ROTFL From Wikipedia: "1-Wire is a device communications bus system designed by Dallas Semiconductor Corp. that provides low-speed (16.3 kbit/s[1]) data, signaling, and power over a single conductor." There is a reason why this is low speed. By specification you don't need high-speed shenanigans like shown in the video and simply by the physics. It is impossible to get a good signal integrity via this bus-implementation at high frequencies. If you are flying up to the 100MHz+ range, nobody can deny technologies like LVDS and the study of high frequency behavior of electronics and the corresponding physics. Also, that the pico can theoretically generate these signals must not mean that he can also DRIVE the signals necessary. Don't get me wrong, please try your (by my understanding) worthless experiments. Maybe with a better bus? At least two wires? Well wired for high frequencies with buffers? The simulator: RTFM, I mean the data-sheet (Reference and Programming) and really ... you need a simulator for a $5 device you can debug and watch at the oscilloscope? Please stop joking ... no, have fun!:)
@@stacksmashing Take for example the very good qemu-arm emulator. It is impossible to translate timings to a real chip. High speed one-wire protocol ... I overthought it: He will try it with or without me. DSO: There are $29 STM32F103 based ones out there which would be fine for 16kbit/s. I don't gave that advice from thin air. To prevent tears and frustration! Low speed applications, but not for 200MHz SPI or something in that region .... which always works and you can as a bonus ... rely on! Skepticism is always not seen as positivity. But thanks that you RTFM and present that here with your videos. Can't wait for a real world app of PIO.
So wait this runs separate from the main code? Man this micro is unbelievable, I want to switch to this, but not sure about the IDE, and Id need to be able to purchase chips.
Any examples of some of the cool things that people have imagined with this type of I/O power? For example, I looked for some logic analyzer or AWG, but nothing on YT shows up!
My goodness, this is some high-level info for low level hardware manipulation. Deffo not for me, but for those who gonna implement various protocols and interface emulation. Thumbs up!
I have this phantasy, where I go back in time with a boatload of these chips. And start selling them, but not as they are. Instead someone wants a ram chip, I gimp this thing down to be a ram chip. Someone wants a rom or a math compressor or a dac or whatever, they are all just this chip repackaged and trimmed down. When someone discovers what I did I leave never to be seen again. Leaving the world to scratch their heads.
The Pi Foundation made the perfect microcontroller board for many. The Micropython appeals normies, and everything else is perfect for low level stuff. This board with its PIO is the best hardware hacking tool ever. The dual core CPU also allows more interesting programming solutions.
"So that's all there is to the state machine, pretty simple" after explaining like 11 different components, some of which have their own sub components in turn
What a nonsense, there surely is an adder since JMP can decrement and yet it is the only instruction that can do some math I appreciate stacksmashing's video a lot, to say its helpful is understatement. Thanks
I have seen reports of the RP2040 being overclocked to 270MHz, but the Pico Dev Board UNDERclocks the CPU to 125MHz ...so remember to calculate your divider based on the clock speed returned by `clock_get_hz(clk_sys)`
This PIO thing is pretty cool, I should learn more about it
Not sure where that leaves the rest of us Luke. 🤦
Once you get the hang of it :-D let us know ... we will bug you for a step by step tutorial that takes us from the pio blink example to writing our own pio stuff. I'm still really puzzled on the raw C helper function
% c-sdk
Pilot Induced Oscillation is a pretty scary thing to get into. :)
The Raspberry Pi Foundation just lit a fire underneath Arduino. The pico is so packed with features and as such appeals to people that have experience with Espressif's chips while at the same time being more than a quarter the price of an Uno plus being more intuitive. They covered everyone with their hardware, they sure did know what they were doing.
You know that you are comparing Apples and Ataris, don't you? In addition, it won't do any harm if Arduino burns down. That was a joke, of course. Frameworks burn badly, or not at all, when they are mental constructs;)
Don't forget: use the right tool for the right job. In some of the comments here you can clearly see how strange a high-speed logic with discrete building blocks is to people. To know about that too can sometimes be an advantage. Or simply have knowledge besides the Arduino, ESP or Raspberry filter-bubble.
www.digikey.com/en/products/filter/embedded-microcontrollers/685 ... Fucking 89483 results!
@@dieSpinnt The AVR market is not going to change, I am just fearful of Arduino's position here. You could get a bare bones AVR chip for a comparable price to the pico even after the demise of Arduino no problem. It would only really show how expensive their stuff are and pressure them to act. Whatever happens, knowledge is knowledge.
@@martandrmc Hmmmm, I can't see us both discussing the (insert MCU here) Market. Who buys, calls!
In retrospect, my thoughts on your Arduino worries to calm you down: If you have to do something quickly, use a BAD editor (I just don't understand why people pick it up. It's a free decision to use a text editor and not code-completion mumbo jumbo or the other way arround) ... in other words: one that works (!) and you want to try something quickly (with thousands of others strengthening your back with their experience through libraries or support), again: something that works ... proven
There is always a niche for this type of hobby or craft work. This niche can be really big, so big that even professionals can use it to quickly try out an idea.
I think you shouldn't worry. Especially not because of diversity :)
May I show you something other besides my inabilities of soldering TQFP packages?
www.st.com/en/microcontrollers-microprocessors/stm32h747-757.html#overview
A powerhouse with camera interface, GPU acceleration and a pin header count that doesn't bring us both to a laughter as the pico. The same free tools and support from an industry leader (let us make jokes, later:)). Raspberry Pi Pico ? I don't see this as god's chip. Don't let you fool from the hype. There are Ten of Thousands out there, if not more ... to choose from.
Edit: I cheated a little: for the price of the Pico, you have to give up graphics acceleration but you have up to 160 flexible IO lines .... You can then connect externally via the memory interface, as well as operate quad SPI memory and what works as a PIO there does a DMA controller for normal people. The one described has 4.
@@dieSpinnt In retrospect, comparing the 2 prices is not by any means the full story. There are devboards out there with an STM32 at around the same price as the pico that have better performance than an Uno but still have not gotten to be main-stream yet. Arduino has alot of software behind it that could also work with a Mega if performance is needed. In conclusion i dont think that Arduino is in as much danger as i have thought, but still the pico is backed by a similarly well-known company. It would not be equivalent to compare STMicro the same way. (Also sorry for not checking for a week)
Finally! someone talking the PIO.
And it has to be our favorite reverse engineer.
I have been around microcontrollers off and on since the MK3870 at the end of the 1970s. Having this level of IO functionality driven by separate execution units with well thought out instruction sets is just mind-blowing in its possibilities. I know other chip families have had smart, programmable IO systems, but this takes it to a new level. As someone who used only to program in assembler for most of the 1980's, I found that this was a great video that explained the capabilities very well. Thanks. Subscribed.
Me too. I spent five solid years working with 6809,8085,Z80,68K and this video has left my mind reeling with questions like "Yes, but what can/can't you do with it?" I've seen one video of a guy who has recreated the original Transputer boards. I learned Occam for a bit on one of those.
This clarifies lots what this board is intended to be, it is not just another microcontroller but a very advanced one. Thanks for the deep explanation
Around 8:25, JMP (X--), the documentation says: JMP X-- and JMP Y-- always decrement scratch register X or Y, respectively. The decrement is not conditional on the
current value of the scratch register. The branch is conditioned on the initial value of the register, i.e. before the
decrement took place: if the register is initially nonzero, the branch is taken. (RP2040 Datasheet, page 320,321)
The emphasis is on ALWAYS so that the decrement is ALWAYS done.
Currently working on a PIO based project, and this video has been a life saver. I'd love see a video that has more examples of how IO mapping works in practice, especially with overlapping pins. Thanks for the great work!
A lot of knowledge, nice video. But I could not quite follow without examples
For sure quite a dry topic, tried my best to create it as a 'reference' :) Next one will have some practical examples, that should help!
Ok cool, cant wait for the next video
Agreed. as stack says, needs to be a reference first...but would be nice to show a very brief example of an instruction executing (like how the effect on square wave is demonstrated).
It would also help if he slowed down a bit. It's difficult to absorb information when it's blasted at you.
@@stacksmashing Maybe videos are not the best medium for a reference, surprising as that may be in the YT age.
I love assembly language for it being so simple yet so complicated.
If I'm programming, I always prefer low level, for some reason.... Yet I hate myself afterwards 😂
Assembly language is delicious!
If you want a good challenge, try implementing string.h
Coming from Amiga programming background I always find myself reinventing the wheel... :) Love the low level stuff!
I haven't watched the whole video yet, but somehow I think that the Amiga co-processor (Copper) has been made to do I/O
After a lot of explanations that are either too vague or too specific, this is a nice concise description of how the PIOs work. Thanks.
Nice to have this video! I've read through the datasheet section, but this helps in visualising how it all comes together
Thank you, that's great to hear! :)
This is the video I've been looking for for the last two months! Thanks! Watching it on loop
Exactly. It's quite complicated if one is new to assembler. .wrap_target at video start :)
This tie up everything together I've read or watched so far about PIO, but never quite get to breaking that threshold of solidifying my understanding of PIO. But the video did it for me. Great job!
I recently got a Pico and a VGA drmo board, and I've spent the last few days getting to know all of the nice peripherals the Pico has. This video is a great overview of the PIO!
Best PIO explanation I've seen so far! Thanks so much. Looking forward to the examples video. I tried to follow the one in hackspace mag but really struggled. I think largely I'm falling down on the buffers and the the shift registers and keep getting lost on what direction things are going relative to what (PIO SM, main cores, or pins/IO). Your diagrams/animations really helped in this video though so thanks for that effort.
WoW !!! exactly to the point , fast paced and covers everything , now when I read the spec. it will make sense ... thanks
this is the BEST !!!
Excellent explanation. Thank you for this video! I reduced the speed of the video to 75% though which helped me watching the video in a more relaxed manner 🙂
You know it's the creme de la creme when you go 0.75 speed :)
Meanwhile, I'm watching at 1.5 and not fully processing everything.
Oh well, I'm just trying to get the gist of it and I'll look at documentation when I'm actually working with it.
@@chinoto1 Lel, I had to jump down to 1.5 from 3.5; video speed controller is my best plugin.
Very concise and visual explanation. I like it very much! It gives a great overview _and_ details
I can't thank you enough for this video, it is very clear, very well structured and very detailed. All other 'tutorials' I've seen pretty much say "PIO is really powerful, you can do amazing stuff. Here's an example of how to flash the on board LED. Work everything else out for yourself".
Great, sounds like an awesome thing to learn asm and how low level stuff actually works. Thanks for the great explanation!
All this bitbanging is great! Takes me back to channel programming IBM/360. What I need now is a slightly higher level helicopter to understand the pico’s application in an architecture dimension.
Great video. Been reading around this all week without making much progress. Feel like I am starting to understand after watching this video. Well done.
Love this video, all I wanted to know in a pretty information-dense format
I absolutely love PIO in my chips. It means you can hook up just about anything you want, unconstrained by physical ports or dedicated controllers. It's almost like a tiny FPGA on your chip. My ultimate goal is to get multiple RP2040s running as a cluster using their PIOs.
I’m actually working on clustering a bunch of picos to rebuild Ben Eater’s 8 bit computer (but planning on using 16 bit addresses instead of 4 bit addresses for memory; 65536 bytes instead of only 16 bytes). It kind of silly to build a (slow) cup out of a bunch of processes but some good things are: lots of lights, ability to experiment with cpu architectures quickly (easier than wiring lots of 7400 series chips), and it’s fun and I just want to haha. Python is good enough but I want to using PIO if possible.
Currently looking into implementing i2s audio using the PIO sm's. It's easy enough to imagine "how to do it" in my head. But I have a hard time grasping "the right way". Been watching videos and read up on the documentation. Some stuff confuses me, some makes sense. This video was helpful, although I did miss some examples for some of the instructions and the whole concept of mapping certain pins to PINS are still a bit confusing to me. I'm a visual guy, so I definitely got more from the first part of the video with the visual aids. Great video nonetheless. :) Thanks.
EDIT: Btw, one thing I am having a very hard time with, is trying to connect my data in my C / C++ code with whatever the sm reads / works on. That whole IRQ, DMA, FIFO, ISR, OSR situation makes my head explode. :D It's probably simpler than it seems. I just need to slowly work my way into it.
Nice to have this video! This helps me to realize my project. But I don't understand the state machine, because from the UML perspective this is not really a state machine. A state machine must have an entry point and transitions between states, including conditions. The exit state is optional.
Not sure where you're getting that definition. If it's from UML, then they've redefined the term. A state machine doesn't need an exit point. And it certainly doesn't need transitions defined between every state (if that's what you meant there). I've built many no-exit state machines, and almost none with all possible transitions allowed.
@@peter9477 de.m.wikipedia.org/wiki/Zustandsdiagramm_(UML) im Vergleich dazu der de.m.wikipedia.org/wiki/Endlicher_Automat
@@mr.unbekannt2163 I'm not sure what you're expecting me to get from that page. Are you claiming something in it contradicts me? Or are you claiming that the UML definition does require all possible transitions to be allowed? (In which case as I said they have redefined the term, and inappropriately, I might add.)
I literally never seen a raspberry pie nor even I am a hardware guy still understood everything in this video
Awesome work!
Gonna watch your all hardware videos!!!
If this post wasn't so 'old', I could have swear it is 100% machine (AI) generated! The speed, rhythm, regularity of reading a text is definitely a robot's voice, no doubt in my mind. Anyways, a good presentation, although a bit superficial.
I like how this was released the same time as Rpf's video that explains PIO (but simply what it is, not how it works).
This is amazing. Thank you for the effort you obviously put into this (and your other) videos.
awesome explanation.
these 8 PIO's will be super useful.
wow, that was a fantastic video! _marlin 2.0 might be able to run on this_
After you've come through the assembly language door with PIO you can carry on down the rabbit hole and program the ARM cores in assembly too!
This looks like the perfect uC to implement some very serious bus sniffers like I2C or SPI. BusPirate has proven to be too slow and unreliable for this, FPGAs as a bit too unapproachable for most.
Thanks - I have been waiting for someone to make this video - you got my sub! I modified the ws2812 RGB example in the python code to work with sk6812 RGBW leds, and it was really hard to find any good examples of exactly what the PIO assembly instructions were doing. And even less info on what the python calls to that code was doing. I hope you will cover this in your future videos. Thanks for all your work.
Thanks, this overview helped a lot to clarify some concepts.
I took this at a high level but thank you for bring this to my attention
Very good introduction into this interesting topic. Thanks for sharing
Quite a bit like the lighting control 'engines' that in the LP5523 LED controller (ca.2006), but maybe without the engine priorities(?), although the pin mux idea is similar. this allows for some pretty fast real-time functionality, without needing cpu intervention, and with a LOT of flexibility. (BTW, if you do need an LED controller that doesn't need you to constantly execute code to do complex LED functions, the LP5523 was designed to offload the cpu, and allow LED functionality when the cpu is in deep sleep, even has an "interrupt" input/output to respond to, or initiate, other hardware functionality.)
I really like this feature in RP2040, I wonder how they come up with it. Is there any other microcontroller that has something like this?
Cypress' PSOC series have fpga like programmable hardware blocks builtin.
It's like a more accessible version of the Parallax Propeller.
This video is amazing. Very comprehensive! Thanks for making it!
Crazy level of presentation my dude! Also, PIOs were the thing that made me interested in the Pico - I'm not even an embedded developer. However, with the Shift Register and its capabilities alone the possibilities are crazy ♥
I love your channel so much and I really want to learn how to use ghidra, I really hope you’ll make more learning videos because I love this field and you can teach concepts and methods really well in my opinion, keep it up please, every video from you is a blast!
So basically, my processor gave me a bunch of more complicated processors for free, and now I have to learn them. Great.
/s
Oooo, this is very interesting! Could be cool to use the pio to hook up some picos together, honestly now I am super excited to get my hands on a batch;
Hi, I think there is another errata to be written: at 7:37 and 14:04 you explain, that "set pins, 1" turns an output ON, whereas at 9:01 you explain it as turning it OFF. Or did I misunderstand something here? Thanks for the great video - that was well-paced with dense information!
You are absolutely correct, great catch! It's off for 1 cycle and on for 2 cycles. Added it to the errata.
Glad you liked it!
Fantastic video - very well done. Do you have a followup video to this? I cannot find it on your channel.
extremely helpful!! i had to play @ 3/4speed because i am from southern US and i listen as slowly as i speak)) i have posted question on rpi-forum about feasibility of pio-state-machines to implement canbus (would need external differential drivers), but sadly no answers. Please reply with opinion if you are familiar with canbus. many thanks for well done vid.
I always really enjoy watching these videos but afterwards I feel like I know nothing xD
This [stacksmashing] thing is pretty cool, I should learn more about it
Thanks for this PIO introduction! I now understand what I read in the datasheet ;o)
I have a question: as IN and OUT pins groups can overlap, how are common pins handled? Do they automatically change direction depending if they are shifted in or shifted out?
I'm asking because I would like to interface the Pico with a Z80 bus, so IN and OUT should point to the same pins...
Great run through.
Very good but very fast in the discussion. Have to rewind and listen a few times to digest the topics. 8:59 example for JMP is documented in reverse? First the output will be OFF and then ON for 2 cycles? Please confirm.
Yeah, I am only just learning about this, but it does seem logically to be a mis-speak in the video. It seems like the pin would be ON for the cycle the JMP instruction takes (and I don't know enough to know if it would be considered to be ON during the instruction cycle it is set ON, or ON during the instruction cycle it is set OFF, but either way, that is two cycles).
Oh... he added a correction to the video description some time ago.
I was surprised to see Pi make this product. What, no linux? I'm in. It reminds me of bit slice programming on the AM2900, or the TPU on the 68332, or Motorola DSCs, or even EPROM based state machines. Now I just gotta think up an application.
Very well-made and informative video, thanks!
I just stumbled upon this and am blown away by this feature. I wanted something like this in the past and was considering programmable logic.
Does anyone know which other processors have this feature? Maybe the raspberry Pi computers?
This was very clear, thanks!
Outstanding explanation!
Now I just need to get my hands on one...
9:08 isn't it off for 1 cycle, on for 2? (the 2nd cycling being the jmp command execution) just checking really.
You are correct, but your timecode is wrong ;)
More like 8:55 but yeah.
Great video. I would love to have this as a document. I’ll run through this slowly and make a lot of notes. It’s very useful. I’d love to know where you got the data from .
Datasheets I presume
datasheets.raspberrypi.com/pico/pico-datasheet.pdf
Really cool, thanks!
Can you do a vid on software tooling and first examples? Seems a lack out there in youtube land, we are all super keen to get PIOing!
This is some smart engineering!
Great info and great animations :)
This is sooo nice! Imagine someone would create a gameboy cartridge with it xD
Someone did! www.reddit.com/r/raspberry_pi/comments/lhym1v/gameboypico_update_we_have_a_working_game_but/
This is actually what i have been waiting for, if i understand it correctly. Thanks for this video! Do i get it right that i can read 8 bit in parallel by only one state machine and write it into memory via dma while data is being transferred via wlan from memory, and all this runs concurrently?
I never fail to be impressed by the features of the rp2040, and it's
12:03 Sorry, but you've got IRQ WAIT the wrong way around. You said "IRQ WAIT waits for it to be clear before setting it". No: IRQ WAIT immediately sets the IRQ but then waits for the IRQ to be cleared again.
I'd like to confirm this should be added to the errata, qv. C SDK #3.4.9.3 : "irq wait Means set the IRQ and wait for it to be cleared before proceeding"
As it always the case 😂
8:28 The Motorola 68000 family had an unusual decrement-and-branch instruction: instead of decrementing and branching until the count reached zero, in which case it would stop branching and fall through (existing the loop), it would decrement to -1 before exiting. This let you deal easily with the case where the loop count was initially zero, in which case you want to just jump over the loop completely. E.g.
move.w #count, d0
bra loop_end
top_of_loop:
.... body of loop ...
loop_end:
dbra d0, top_of_loop
So had the Z80: 'djnz address', which stands for Decrement and Jump if Not Zero, where register b (8 bit) was the one being decremented. But these very rare and useful instructions (for creating loops) have not much to do with this discussion about PIO, which are far more complex and programmable!
16:33 Those are just labels that don’t have any special meaning to the assembler. The CPU program then has to set the values of these labels into the relevant PIO registers to enable wrapping.
Wow amazing video :D
Great video, Thanks for your efforts, It is very useful.
Thank you, sir!
Great vis. How did you make these animations?
Thanks, cool video. Can the PIO instructions read analog inputs?
is there a cheatsheet on the io pins commends?
I'm going to want to make a specialized one wire serial adapter with this thing one day.
Edit:
Is there a simulator for this? I don't have the hardware to debug the input and output of one of these, would love to be able to provide some basic pin states over time and be able to plot what it does over time.
Search for "Signal/Noise Ratio". One Wire ... ROTFL
From Wikipedia: "1-Wire is a device communications bus system designed by Dallas Semiconductor Corp. that provides low-speed (16.3 kbit/s[1]) data, signaling, and power over a single conductor."
There is a reason why this is low speed. By specification you don't need high-speed shenanigans like shown in the video and simply by the physics. It is impossible to get a good signal integrity via this bus-implementation at high frequencies. If you are flying up to the 100MHz+ range, nobody can deny technologies like LVDS and the study of high frequency behavior of electronics and the corresponding physics. Also, that the pico can theoretically generate these signals must not mean that he can also DRIVE the signals necessary.
Don't get me wrong, please try your (by my understanding) worthless experiments. Maybe with a better bus? At least two wires? Well wired for high frequencies with buffers?
The simulator: RTFM, I mean the data-sheet (Reference and Programming) and really ... you need a simulator for a $5 device you can debug and watch at the oscilloscope? Please stop joking ... no, have fun!:)
@@dieSpinnt If you want me to get a DSO by all means send me the money.
@@gudenau Nope. I am not forcing you into something. You can live without one, but then ... you simply can't do what you are trying to do. Just that:)
Jedzia you should really overthink your attitude, you are not contributing positively.
@@stacksmashing Take for example the very good qemu-arm emulator. It is impossible to translate timings to a real chip.
High speed one-wire protocol ... I overthought it: He will try it with or without me.
DSO: There are $29 STM32F103 based ones out there which would be fine for 16kbit/s. I don't gave that advice from thin air. To prevent tears and frustration!
Low speed applications, but not for 200MHz SPI or something in that region .... which always works and you can as a bonus ... rely on!
Skepticism is always not seen as positivity. But thanks that you RTFM and present that here with your videos. Can't wait for a real world app of PIO.
mal kurz weg vom nüntändö, hehe. didn't know that you can do so naice stuff with pio - fantastic.
this video is very helpful
So wait this runs separate from the main code?
Man this micro is unbelievable, I want to switch to this, but not sure about the IDE, and Id need to be able to purchase chips.
This reminds me a lot of the code in Shenzhen I/O.
Wow, I didn't realize the Raspberry PI Pico's have been out for 2 years now.
Any examples of some of the cool things that people have imagined with this type of I/O power? For example, I looked for some logic analyzer or AWG, but nothing on YT shows up!
this is awesome
My goodness, this is some high-level info for low level hardware manipulation. Deffo not for me, but for those who gonna implement various protocols and interface emulation. Thumbs up!
Nice job! Thanks :)
Thank you!
Aren't the arrows for RX and TX backwards on the shift register slide?
ISR IN has a RX FIFO arrow pointing away from ISR IN. (and Vice versa for out)
(at time 2:59)
IGNORE my IGNORANCE... all relative to GPIOs. So input from GPIO's to FIFO buffers, to CPU(?).
Sad you didnt make some examples. But overall a great vid. Thanks
He links to examples in the description
@@trhosking my bad. Thanks
great video . but where is the next vifeo you mentioned😂
Your English accent is so adorable 🥰
I have this phantasy, where I go back in time with a boatload of these chips. And start selling them, but not as they are. Instead someone wants a ram chip, I gimp this thing down to be a ram chip. Someone wants a rom or a math compressor or a dac or whatever, they are all just this chip repackaged and trimmed down. When someone discovers what I did I leave never to be seen again. Leaving the world to scratch their heads.
I’m not clear: what is application for this? Maybe any examples? Do you continue?
MOV Y, Y How about adding a *NOP* instruction instead.
On a lot of architectures (like arm) no actual NOP instruction exists. Instead NOP will be encoded by the assembler to be i.e. MOV r0, r0.
The Pi Foundation made the perfect microcontroller board for many. The Micropython appeals normies, and everything else is perfect for low level stuff. This board with its PIO is the best hardware hacking tool ever. The dual core CPU also allows more interesting programming solutions.
I will make document from this it’s great. Do you have access to more info ?
"So that's all there is to the state machine, pretty simple" after explaining like 11 different components, some of which have their own sub components in turn
What a nonsense, there surely is an adder since JMP can decrement and yet it is the only instruction that can do some math
I appreciate stacksmashing's video a lot, to say its helpful is understatement. Thanks
Is PIO fast enough to emulate the bus operation of an 8 MHz CPU?
I want to hardware emulate an 8086.
3:05 wait, since the Arduino core for the Pico allows for overclocking to ~250MHz does that also make the PIO run faster?
Yes, PIO runs with system clock (so 250MHz overclocked) or you can set it to custom, lower frequency via a divider.
I have seen reports of the RP2040 being overclocked to 270MHz, but the Pico Dev Board UNDERclocks the CPU to 125MHz ...so remember to calculate your divider based on the clock speed returned by `clock_get_hz(clk_sys)`