RP2040 - PIO and Bare Metal Programming - BMA06

Sdílet
Vložit
  • čas přidán 5. 07. 2024
  • RP2040 - PIO and Bare Metal Programming - BMA06
    Join David for this very special crossover event where Bare Metal Adventures meets the PIO Chronicles. In this video, we will invoke Programmable Input Output while using Assembly language but WITHOUT using the SDK. We will also hand assembly the PIO code. This is great information for anyone who wants to really understand the workings of PIO down at the register level.
    Raspberry Pi Pico Assembly Language Tutorial #06
    Resources for this Chapter::
    Demonstration files for this video:
    github.com/LifeWithDavid/Rasp...
    Link to Register worksheet:
    github.com/LifeWithDavid/Rasp...
    Link to “Bare Metal Adventures, Chapter 04”:
    • RP2040 - NO SDK! Assem...
    Link to “Bare Metal Adventures, Chapter 05”:
    • RP2040 - System Clocks...
    Link to “PIO Chronicles, Episode 4”:
    • Raspberry Pi Pico PIO ...
    Link to “PIO Chronicles, Episode 7”:
    • Raspberry Pi Pico PIO ...
    Link to “PIO Chronicles, Episode 10”:
    • Raspberry Pi Pico PIO ...
    Link to “PIO Chronicles, Episode 11”:
    • Raspberry Pi Pico PIO ...
    Cortex-M0+ Generic User Guide: developer.arm.com/documentati...
    ARMv6-M Architecture Reference Manual:
    developer.arm.com/documentati...
    RP2040 Datasheet: datasheets.raspberrypi.com/rp...
    Getting Started with the Raspberry Pi Pico: datasheets.raspberrypi.com/pi...
    Emulator cpulator.01xz.net/?sys=arm-de...
    ARM Assembly Language Tutorial: • Assembly Language Prog...
    00:00 - Introduction
    01:02 - PIO Review
    03:15 - PIO Register Overview
    03:44 - Our PIO Assembly Program - Getting Started
    04:22 - Bringing the PIO out of reset
    06:19 - Hand compiling the PIO Instructions
    11:18 - Loading the PIO Instructions
    13:29 - Setting up the PIO output pins
    17:24 - Setting the State Machine Clock Frequency
    18:31 - PIO program Wrap Bottom and Wrap Top
    19:52 - Restarting and Enabling the State Machine
    21:27 - Putting it all together
    22:31 - Closing
    Music:
    (Pinnacle 25 royalty-free music):
    Pulsing Dance
    City Night Groove

Komentáře • 42

  • @AbcXyz-ks1rv
    @AbcXyz-ks1rv Před 10 měsíci +2

    Thanks for this series. I couldn't find many CZcams Videos that talk about ARM assembly language on PI. In my college they are only teaching how to program M0 on Keil. But doing it on an actual board seems a lot more fun.

    • @LifewithDavid1
      @LifewithDavid1  Před 10 měsíci +2

      And it only cost a few bucks! Thanks for watching.

    • @bobweiram6321
      @bobweiram6321 Před 10 měsíci

      ARM assembly is compatible across all the ARM processors and MCUs. The PI uses an M0+ an enhanced version of the M0.

  • @jemo_hack
    @jemo_hack Před 10 měsíci +2

    awesome work!

  • @sapiosuicide1552
    @sapiosuicide1552 Před 8 měsíci

    I'm loving this series, amazing work. I always love seeing how these things work under the hood and you do a great job of explaining. Keep it up!

    • @LifewithDavid1
      @LifewithDavid1  Před 8 měsíci

      Thank you!. Glad you enjoyed it and thanks for watching!

  • @mytechnotalent
    @mytechnotalent Před 8 měsíci

    You are the best David I truly appreciate and love your work. Especially Assembler. I am an old timer who grew up learning 6502 Assembler for my first programming language.

    • @LifewithDavid1
      @LifewithDavid1  Před 7 měsíci

      Thanks. My next project combines assembly for both the
      RP2040 and the 6502.

    • @mytechnotalent
      @mytechnotalent Před 7 měsíci

      @@LifewithDavid1 can't wait David!

  • @kippie80
    @kippie80 Před 10 měsíci +2

    Nice work! I was surprised how long it took to load PIO program, you must have put a delay in there, load one word with each flash. I'd missed that.

    • @LifewithDavid1
      @LifewithDavid1  Před 10 měsíci +1

      Yes, I put in a long delay. While I was debugging, the only feedback I had was blinking lights; so I added long delays so I could see them blink. Look at the program in Github, and you'll see the blink subroutine.

    • @danman32
      @danman32 Před 7 měsíci

      I thought the same thing, why so slow to load the PIO program? Then I remembered you used the blink routine

  • @MordecaiV
    @MordecaiV Před 10 měsíci

    Just what I was looking for!

  • @mytechnotalent
    @mytechnotalent Před 8 měsíci

    I hope you make 1000 more videos in Assembler for the Pico.

  • @edgeeffect
    @edgeeffect Před 10 měsíci

    My first visit to your channel... I'm massively into assembly language... in recent years doing a lot of AVR... I've been having lustful thoughts about the 4020's PIO for a while.... I think there might be some good stuff here.
    I love your desk set... I feel like I'm watching TV in the 1980s :)
    When you show program and datasheet extracts... It'd be better if you were more zoomed in... my eyesight isn't what it was AND I'm watching on a phone.

    • @LifewithDavid1
      @LifewithDavid1  Před 10 měsíci +1

      Welcome aboard! I hope you find it challenging enough. I was into assembly back on the 70's and I'm getting back into it now with ARM. I've got a few more things planned on assembly.
      Regarding the zooming of the program and data sheet, it's difficult to get everything in context. I try to optimize it for someone on a computer. I try to make it bigger than most CZcams channels, but it's tough to get everything on a phone. I'll try to make it a little bigger in the future.

  • @danman32
    @danman32 Před 7 měsíci

    Love these seies. Found them because i was trying to find a way to drive a 16x300 neopixel array using 16 channels to drive the 16 rows, then use graphics primative libraries mainly to draw text to the array.
    I found someone using a 74HC 8 bit serial to parallel shift register and PIO to provide 8 row channels. Thats easily adapted to 16 channels but the challenge is transposing the bits in the frame. Circuit Python has a quick transpose routine, but only handles transposing 8 bits at a time. I need 16.
    I could probably do that in C but would it be fast enough to transpose 14K of a frame buffer before i show the results?
    Or if the transposer is fast enough, perhaps with a 2nd PIO, transpose 16 pixels (48 bytes, since each pixels is 24 bits, offset by row size) in time?

    • @LifewithDavid1
      @LifewithDavid1  Před 7 měsíci

      I don't know if you checked out my "PIO Chronicles" series? I did a high speed AWG where I could generate up to a 25 mHz (with poor resolution) sine wave using PIO (czcams.com/video/8ByDgh5-O2U/video.html). I also did VGA video using PIO (czcams.com/video/ZEBkM5FQ86Q/video.html. Maybe those will give you a few more ideas. Sounds interesting. Good luck and have fun!

    • @danman32
      @danman32 Před 7 měsíci +1

      ​@@LifewithDavid1 Yes, it is with these during my search for answers that I came across your channel. Didn't get through all of them yet but gave me hope with my large Neopixel array.
      Since I found Adafruit C libraries that I likely can adapt, writing an array transpose function in C: likely will be fast enough to get a decent framerate.

  • @jonathanstein6056
    @jonathanstein6056 Před 8 měsíci

    Hey, David. Great series! Any chance of getting back to the 6502 and PIO? You seem to have mastered the pico. It would be cool to see you connect the PIO to the 6502 and use the pico for ram and rom.

    • @LifewithDavid1
      @LifewithDavid1  Před 8 měsíci +1

      I'm hoping to do several videos where I design a 6502 emulator on the Pico. I've made some good progress and I hope to have something to present in a couple weeks. Thanks for the comment!

    • @jonathanstein6056
      @jonathanstein6056 Před 8 měsíci

      @@LifewithDavid1 thanks for the reply! An emulator would be neat, but I was thinking more along the lines that you originally started with, i.e., a real 6502 (or 65C02) hooked up to the PIO. Actually, you could use a few pico/6502 “units” together to make a pretty interesting multi-cpu project. Unified memory architecture. Just a thought. Nobody has done that that I’m aware of. You certainly have the know-how!

    • @LifewithDavid1
      @LifewithDavid1  Před 8 měsíci +1

      ​@@jonathanstein6056 That would be an interesting project. Not sure when I'll get to it; I've only just scratched the surface of what the Pico can do. I would also like to revisit VGA video. So much to do and so little time!

    • @jonathanstein6056
      @jonathanstein6056 Před 8 měsíci

      @@LifewithDavid1 I hear ya. Keep up the great work 👍🏻

  • @wktodd
    @wktodd Před 10 měsíci +1

    Can you use the wrap target instead of a jmp?

    • @LifewithDavid1
      @LifewithDavid1  Před 10 měsíci +2

      Yes you can. I could have replaced the jump with a wrap. This would save one space in PIO memory and also save the instruction execution time for the jump instruction since the wrap doesn't use any time. See my PIO episode 4 for more information. I used the jump because I wanted to slow things down. Thanks for watching!

  • @edgeeffect
    @edgeeffect Před 9 měsíci

    It'd be nice to define a bunch of macros so you could write PIO assembly instructions in your ARM code and they'd emit the correct .word directives... I don't know if this is possible but the idea tickled my "wouldn't it be cool if...".

    • @LifewithDavid1
      @LifewithDavid1  Před 9 měsíci +1

      Interesting. It's operation would be similar to pioasm. If we used the C/C++ SDK then we could call pioasm to generate the .word directives. Thanks for the comment!

    • @danman32
      @danman32 Před 7 měsíci

      I thought the same thing: can't we use a PIO assembler to generate the opcodes?
      Probably could be done in Python but I hate using Python as helper programs. I've often felt it has been overused in today's programs, making them much slower than they need to be.
      My first thought was using a spreadsheet. I did that for generating machine code from opcodes for Ben Eater's 8 bit processor I built and modified.

  • @siriokds
    @siriokds Před 2 měsíci

    Hi David, may I ask you to show us a way to interact with z80 bus via the PIOs in order to use a Pico to emulate a rom ?

    • @LifewithDavid1
      @LifewithDavid1  Před 2 měsíci +1

      Thanks for the suggestion. I will add it to my list of interesting projects. It might be a while; probably after I try emulating a full Apple II.

  • @TooSlowTube
    @TooSlowTube Před 10 měsíci

    What software did you have to install to be able to assemble it?

    • @LifewithDavid1
      @LifewithDavid1  Před 10 měsíci +3

      In "Bare Metal Adventures"; I started out using the GCC assembler (ASM) and the RP2040 C/C++ SDK. However, in Chapter 4, I ditched the SDK, and used the GCC assembler and linker; as well as Make. I would suggest looking at the other videos in the "Bare Metal Adventures". Everything I wrote is located in Github with links in the videos' descriptions. Good luck and thanks for watching!

    • @TooSlowTube
      @TooSlowTube Před 10 měsíci

      @@LifewithDavid1 Thanks. I've used GCC a little bit, with the STM32F407G Discovery board, but only in C++. I've mostly just stuck to Arduino and the Earle Philhower core, for the RP2040. I'll slowly work my way through your other videos :)

    • @dieSpinnt
      @dieSpinnt Před 10 měsíci

      @@TooSlowTube Your statement/thought is wrong. You NEVER used ANYTHING OTHER than GCC. Guess what Arduino uses as its toolchain for your STM32? Or Avr? Or RPi? You get it ...:) There is nothing wrong using the Arduino(-"IDE"). It is just a fancy Make, coupled with a rudimentary editor and package manager, hiding most things that happen under the hood from the user. If you need flexibility, use your own toolchain or build system and editor. Nobody holds you back (only the limited time we have on this earth). Have fun!:)

  • @haryoulimohamed3891
    @haryoulimohamed3891 Před měsícem

    Thanks David. I want to sample ANALOGUE Signal with PIO. Can you give Idee. Please

    • @LifewithDavid1
      @LifewithDavid1  Před měsícem

      PIO processed digital data, either converting to serial, or inputting or outputting multiple bits to GPIO. Converting from analog requires the ADC which is a slow process. I haven't tried it, but you might be able to string DMA together with PIO to automate the process. Good luck!

    • @haryoulimohamed3891
      @haryoulimohamed3891 Před měsícem

      @@LifewithDavid1 Thank you for your answer. You mean that the analog signal is sampled with an ADC and the sampled data is transferred to PIO with a DMA channel to output parallel data. Is that correct?

    • @LifewithDavid1
      @LifewithDavid1  Před měsícem

      Yes, that's what I was thinking. However; I have not done any research into this; so I have no clue if it will work. If you find out; let us know. Thanks for watching!