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

    spi on fopy

    Scheduled Pinned Locked Moved FiPy
    fipy
    6 Posts 2 Posters 1.2k Views 2 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
      misterlisty
      last edited by misterlisty

      Want to use mosi on the fipy but it says it's a external antenna switch. What is this pin for and can I use this pin for spi?

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

        @misterlisty Since this P12 is used for the antenna switch, you cannot use it for MISO. But you can use any other Pin for SPI. P12 is just the default setting. You can specify these Pins in the constructor of the SPI object (see the docs: https://docs.pycom.io/chapter/firmwareapi/pycom/machine/SPI.html). Please consider, that P13 to P18 are input only, so they cannot be used for MOSI or CLK, and P15, P17 and P18 are used for the LTE modem.
        That's the downside of the many functions: fewer Pins available for own usage.

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

          thanks, when i setup SPI, what if i just want to setup MOSI pin? is this possible? The syntax appears to want clk, mosi, miso

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

            @misterlisty You would at least need CLK and MOSI. But if you want to change only one Pin, you could specify the default values for the others.

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

              chain = WS2812(spi_bus=2,ledNumber=3)
              data = [
                   (255, 0, 0),    # red
                   (0, 255, 0),    # green
                  (0, 0, 255)    # blue
              ] 
              chain.show(data)
              
              #modified part of ws2812
               def __init__(self, spi_bus=0, ledNumber=1, intensity=1):
                  """
                  Params:
                  * spi_bus = SPI bus ID (1 or 2)
                  * led_count = count of LEDs
                  * intensity = light intensity (float up to 1)
                  """
                  self.led_count = ledNumber
                  self.intensity = intensity
              
                  # prepare SPI data buffer (4 bytes for each color)
                  self.buf_length = self.led_count * 3 * 4
                  self.buf = bytearray(self.buf_length)
              
                  # SPI init
                  self.spi = SPI(spi_bus, SPI.MASTER, baudrate=3200000, polarity=0, phase=1, pins=('P23','P22')) #modified
              
                  # turn LEDs off
                  self.show([])
              

              Get an error on line 56..resource not available...

              line 56= self.spi = SPI(spi_bus, SPI.MASTER, baudrate=3200000, polarity=0, phase=1, pins=('P23','P22'))

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

                @misterlisty From the docs "(spi_)id can only be 0". And you have to specify the MISO pin

                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