Skip to content

Add some examples, improve the assembler #11

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 12 commits into from
Feb 25, 2021
Merged

Conversation

jepler
Copy link
Contributor

@jepler jepler commented Feb 25, 2021

Assembler improvements:

  • diagnose duplicate labels
  • better diagnostic for jmp to invalid label

Examples:

  • "3 levels of led brightness" from the micropython book
  • "hello" example from pico-examples (turn an LED on and off while needlessly using PIO)

@jepler jepler requested a review from tannewt February 25, 2021 15:24
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thanks for these improvements! Just a few comments.

Comment on lines +92 to +93
if target[:1] in "0123456789":
assembled[-1] |= int(target)
Copy link
Member

Choose a reason for hiding this comment

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

This check will only work for single digit targets but it could be up to 32. Instead, you could try and int(target) and then catch the error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not quite, but maybe the code is too clever as written. It looks whether the first character (if present) in target is a digit.

sm = rp2pio.StateMachine(
assembled,
frequency=80,
init=adafruit_pioasm.assemble("set pindirs 1"),
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't need this init or the set pin anymore.


sm = rp2pio.StateMachine(
assembled,
frequency=80,
Copy link
Member

Choose a reason for hiding this comment

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

The state machine can't go this slow and CP should now raise an error to tell you that.

Copy link
Member

@tannewt tannewt 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! Thank you!

@tannewt tannewt merged commit 94dccca into main Feb 25, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 27, 2021
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.

2 participants