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

    Scheduled Pinned Locked Moved WiPy 2&3
    spi wipy 2.0
    4 Posts 2 Posters 670 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
      Ma
      last edited by

      I should drive the signal data to 2 display, so I would like to use SPI. Can I use two SPI ? How can I configure two different SPI? Is it correct?

      spi = SPI(0) 
      spi2 = SPI(0)
      spi.init(mode=SPI.MASTER, baudrate=40000000, polarity=0, phase=0, bits=8, pins=('P20','P19', 'P18'))
      spi2.init(mode=SPI.MASTER, baudrate=40000000, polarity=0, phase=0, bits=8, pins=('P8','P11', 'P14'))
      
      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @Ma
        last edited by

        @ma SPI used a shared bus. So you can connect both devices to the the same SPI interface. Only the CS (chip select) pins must be different and be activated alternatively.

        M 1 Reply Last reply Reply Quote 0
        • M Offline
          Ma @robert-hh
          last edited by

          @robert-hh thank you. I'm using:

          spi.write(bytes([0x01, 0x02, 0x03, 0x04, 0x05]))
          

          can I use a different way to write with SPI? I need to be faster

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

            @ma If the data is is fixed, you can preallocate the bytes string like:

            data = b"\x01\x02\x03\x05"
            # and later
            spi.write(data)
            

            But that only saves some time before the writing starts. The writing speed itself will not be affected and is most likely slower than 40 MHz. The baud rate you specify is just an upper limit.

            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