Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Assembler in micropython

    Scheduled Pinned Locked Moved MicroPython
    micropythonassemblerfunctionsws2812ws2812b
    10 Posts 3 Posters 1.2k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      maerkl24
      last edited by

      Hey guys,

      is it possible to write functions or code snippets in assembler for WiPy 3.0, and how to do that?

      In micropython documentation i found this command @micropython.asm_thumb but it doesn't work. The error message i get says: SyntaxError: invalid micropython decorator.

      Bit to my personal project i 'm working on. I want to drive three WS2812B led stripes. So i need very exact timing for that. Fist solution was to use SPI like the existing WS2812 librarys for micropython are doing. That's working but there is only one SPI module on the WiPy and i don't want to change the routing of it all the time i have to send something. Another idea was to use the RTM modules but there are only two with 100ns resolution. Last idea is to control the pins directly, but only toggling them with the standard micropython commands take more than 5us so that's no solution. So the idea is to write it in assembler but i don't know how to include that into micropython files.

      Hopefully someone can help me ;-)

      Sorry for bad english. Best wishes from germany.

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @maerkl24
        last edited by

        @maerkl24 Assembler is only available in the micropython.org branch of micropython. About using RMT: you surely have seen this litte driver: https://github.com/robert-hh/WS2812
        If you do not need to drive all three stripes at the same time, you may use the same RMT channel but switch between the Pins. And is there a specific reason why you do not cascade the three strips, using just one channel & Pin? Obviously you would have to rewrite all LEDs all the time, but unless you have really MANY leds, this is not a problem.

        1 Reply Last reply Reply Quote 3
        • M Offline
          maerkl24
          last edited by

          @robert-hh Thanks for the information, i already thought that the access to assembler through micropython is not ported for WiPy. I already found some drivers, but i haven't seen this one yet, so thanks for that.

          I only cascade them not, because of the wiring. Of course I could do that an easier way, but i'm someone who likes to go the harder way. But this time i think i switch the channel between the Pins and go the easier way. :D

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @maerkl24
            last edited by

            @maerkl24 Using the RMT module make pretty reiliable timing. I also tried using SPI, but that does not work reliable on the pycom devices. SPi is not sending the data in a single long burst, but word-wise. And the gaps between words are not guaranteed to have a maximal duration.

            1 Reply Last reply Reply Quote 1
            • J Offline
              jcaron
              last edited by

              Don't forget there's an alternative to the WS2812: the APA102 uses real SPI. They're also marketed by Adafruit as Dotstar (while the WS2812 is the Neopixel).

              Depending on your project, it may simplify things quite a bit to use those.

              robert-hhR 1 Reply Last reply Reply Quote 1
              • robert-hhR Offline
                robert-hh @jcaron
                last edited by

                @jcaron It is deinitely easier to deal with the AP102 devices. With the additional clock signal synchronized to the data timing constraints are gone.

                1 Reply Last reply Reply Quote 0
                • M Offline
                  maerkl24
                  last edited by

                  @jcaron, @robert-hh Thanks for your reply. I knew there is an alternative but i already forgot that, so thanks for reminding me to that, i will keep that in mind. But this project i will finish with the WS2812B because the hardware is already finished.

                  But a last question, is there no other way to access the hardware faster?
                  For my opinion, as a good C and assembler programmer, it would be a shame. :D
                  Seems like this is something i have to deal with in micropython but i also know and like the advantages of it.

                  robert-hhR J 2 Replies Last reply Reply Quote 0
                  • robert-hhR Offline
                    robert-hh @maerkl24
                    last edited by

                    @maerkl24 As far as I know, no. The Machine code emitter has not been implemented for the ESP32. It exists for the ESP8266 in the micropython.org branch. So it may be to port it. But it's not done yet.

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      jcaron @maerkl24
                      last edited by

                      @maerkl24 If you build your own firmware, you can add any code you want in there, though it's quite a bit of work to make that accessible from the micro python code I suppose (and it's a lot more cumbersome to develop as you need to rebuild and reflash the firmware for each change).

                      1 Reply Last reply Reply Quote 0
                      • M Offline
                        maerkl24
                        last edited by

                        @robert-hh, @jcaron Thanks again for the reply. I knew about the possability to build own firmware but i don't know how to do that and it's going way to far. So i will use the RTM module and multiplex the pins. Haven't tried it yet because actual i'm doing my Bachelor Thesis and i don't have much time for personal projects.

                        1 Reply Last reply Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • 1 / 1
                        • First post
                          Last post

                        Pycom on Twitter

                        Pycom