Skip to content

Add sideset assembly support. #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 26, 2021
Merged

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Dec 22, 2021

You must also set sideset_enable when creating the rp2pio.StateMachine
object.

Fixes #16 and fixes #21.

This needs adafruit/circuitpython#5766

You must also set `sideset_enable` when creating the rp2pio.StateMachine
object.

Fixes adafruit#16 and fixes adafruit#21.
@tannewt
Copy link
Member Author

tannewt commented Dec 22, 2021

@dannystaple Please try this out. Note that it'll need a new CircuitPython build as well.

@dannystaple
Copy link
Contributor

Which build? Will the 7.1.0-beta-3 build do this or do I need to pick up a CI artefact for it?

@dannystaple
Copy link
Contributor

Ok - not sure this is working. Perhaps I'm missing something.
My code:

.program pwm_prog
.wrap_target
.side_set 1 opt                ; 1 sideset pin, optional.

    set x 5           side 0
    set y 10         
pwmloop:
    jmp x!=y skip           ; skip if they are different
    nop             side 1  ; drive side set pin high (which will be the one time they are the same)

skip:
    jmp y-- pwmloop         ; decrement x and go to pwm loop.
.wrap

(I know we can ignore wrap/wrap target)

The output assembled:

000 111_10000_001_00101
001 111_00000_010_01010
010 000_00000_101_00100
011 101_11000_010_00010
100 000_00000_100_00010

I think I am expecting:

000 111_10001_001_00101 
001 111_00001_010_01010 
010 000_00001_101_00100 
011 101_11000_010_00010 
100 000_00001_100_00010 

I could be wrong though.

I have used the 7.1.0-beta3, and just to be sure I was loading your code, called the module adafruit_pioasm_tst, and imported that. Assembly:

pwm_prog = adafruit_pioasm_tst.assemble(pwm_prog_raw)

FYI - the output I made with this, on the Pico:

instructions = ('{:016b}'.format(inst) for inst in pwm_prog)
formatted = ("{i}_{ss}_{src}_{dst}".format(
    i=inst[0:3],
    ss=inst[3:8],
    src=inst[8:11],
    dst=inst[11:16]
) for inst in instructions)

numbered =  ['{:03b} {}'.format(line, inst) for line, inst in enumerate(formatted)]

print('\n'.join(numbered))

@dannystaple
Copy link
Contributor

Wait - being a donut. I made those expected things based on your unit tests. The last bit shoudln't be set - that was because you had a [1] in the test code I used to get example bits from. I might be getting what I mean.

@dannystaple
Copy link
Contributor

Confirmed - output with the old library:

000 111_00000_001_00101
001 111_00000_010_01010
010 000_00000_101_00100
011 101_10000_010_00010
100 000_00000_100_00010

It's subtle - but it's the 1 for side set 0 and 11 for side set 1 that makes the difference. Time to get the scope out and check that it does what I think it should (it's a really stupid fixed pwm).

@tannewt
Copy link
Member Author

tannewt commented Dec 23, 2021

Absolute newest builds should work with this now.

@tannewt tannewt requested a review from jepler December 23, 2021 19:22
Copy link
Contributor

@dannystaple dannystaple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. It tests out with the right bytecode, comes with tests and example code.

Copy link
Contributor

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@jepler jepler merged commit d43cdd0 into adafruit:main Dec 26, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Dec 30, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x to 1.11.10 from 1.11.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_ADXL34x#31 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_AM2320 to 1.2.10 from 1.2.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_AM2320#24 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_AS726x to 2.0.7 from 2.0.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_AS726x#18 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_BME280 to 2.6.8 from 2.6.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_BME280#58 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_BME680 to 3.4.1 from 3.4.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_BME680#47 from adafruit/dhalbert-ustruct

Updating https://github.com/adafruit/Adafruit_CircuitPython_BMP280 to 3.2.10 from 3.2.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_BMP280#34 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_BMP3XX to 1.3.8 from 1.3.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_BMP3XX#20 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_Fingerprint to 2.2.2 from 2.2.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Fingerprint#40 from adafruit/dhalbert-patch-1
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_FocalTouch to 1.2.9 from 1.2.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_FocalTouch#22 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_FXAS21002C to 2.1.11 from 2.1.10:
  > Merge pull request adafruit/Adafruit_CircuitPython_FXAS21002C#25 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_FXOS8700 to 2.1.10 from 2.1.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_FXOS8700#26 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_HTU21D to 0.11.2 from 0.11.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_HTU21D#18 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_L3GD20 to 2.3.8 from 2.3.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_L3GD20#26 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS0 to 2.2.8 from 2.2.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM9DS0#24 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS1 to 2.1.11 from 2.1.10:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM9DS1#34 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_MAX31855 to 3.2.10 from 3.2.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_MAX31855#26 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx to 2.5.2 from 2.5.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_MCP230xx#46 from tekktrik/feature/add-typing
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_MLX90393 to 2.0.8 from 2.0.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_MLX90393#30 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_MMA8451 to 1.3.9 from 1.3.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_MMA8451#20 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_MPL3115A2 to 1.2.9 from 1.2.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_MPL3115A2#21 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display to 3.10.10 from 3.10.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#100 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_Seesaw to 1.10.5 from 1.10.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_seesaw#91 from adafruit/dhalbert-ustruct

Updating https://github.com/adafruit/Adafruit_CircuitPython_SHT31D to 2.3.8 from 2.3.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_SHT31D#24 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_SI7021 to 3.3.6 from 3.3.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_SI7021#25 from adafruit/dhalbert-ustruct
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT to 5.1.6 from 5.1.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#96 from FoamyGuy/fix_ci_checks

Updating https://github.com/adafruit/Adafruit_CircuitPython_PIOASM to 0.5.0 from 0.4.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#27 from tannewt/sideset_enable
  > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#26 from dannystaple/main
  > update rtd py version

Updating https://github.com/adafruit/Adafruit_CircuitPython_PYOA to 2.5.2 from 2.5.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_PYOA#32 from FoamyGuy/fix_docs_build

Updating https://github.com/adafruit/Adafruit_CircuitPython_WSGI to 1.1.7 from 1.1.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_WSGI#12 from dbisu/regex-update
  > update rtd py version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Example pwm.pio re-implementation not working .side_set N opt is not currently implemented
3 participants