element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum RP2040 PIO Sideset enable bit is automagically set in uPython
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 0 replies
  • Subscribers 662 subscribers
  • Views 1049 views
  • Users 0 members are here
Related

RP2040 PIO Sideset enable bit is automagically set in uPython

scottiebabe
scottiebabe over 3 years ago

Thanks to BigG I was made aware of a feature in the RP2040's statemachines where the sideset value can be latched and doesn't need to be defined for every instruction.

Posting here, not to overhelm their amazing project. Taking an I2S pio program as an example:

@rp2.asm_pio(out_shiftdir=0, autopull=True, pull_thresh=32, out_init=[PIO.OUT_LOW],sideset_init=[PIO.OUT_LOW]*2,fifo_join=PIO.JOIN_TX)
def samplepio():
    wrap_target()
    label('entry')
    set( x, 14)             .side(0b11)
    label('bitloop1')
    out( pins, 1 )          .side(0b10)
    jmp(x_dec, 'bitloop1')  .side(0b11)
    out( pins, 1)           .side(0b00)
    set( x, 14)             .side(0b01)
    label('bitloop0')
    out( pins, 1)           .side(0b00)
    jmp( x_dec, 'bitloop0') .side(0b01)
    out( pins, 1 )          .side(0b10)
    wrap()

When I print out the assembled machine code for this pio routine using:

addr = 0
for instr in samplepio[0]:
    bcode = '{:016b}'.format(instr)
    print('{:02X}: {:} {:} {:}'.format(addr,bcode[0:3],bcode[3:6],bcode[6:]))
    addr +=1

I get the following:

00: 111 110 0000101110
01: 011 100 0000000001
02: 000 110 0001000001
03: 011 000 0000000001
04: 111 010 0000101110
05: 011 000 0000000001
06: 000 010 0001000101
07: 011 100 0000000001

You can see only 2 bits are used for the sideset values.

If I comment out one sideset directive, then uPython automagically enables the sideset enable bit and the instructions now appear as:

00: 111 111 0000101110
01: 011 110 0000000001
02: 000 111 0001000001
03: 011 100 0000000001
04: 111 101 0000101110
05: 011 100 0000000001
06: 000 101 0001000101
07: 011 000 0000000001

I commented out the last sideset directive and you can see the presence of an enable/latch bit on all previous instructions.

Thanks to BigG, I learned something new!!!

  • Sign in to reply
  • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube