Closed tannewt closed 2 years ago
@dannystaple Please try this out. Note that it'll need a new CircuitPython build as well.
Which build? Will the 7.1.0-beta-3 build do this or do I need to pick up a CI artefact for it?
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))
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.
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).
Absolute newest builds should work with this now.
You must also set
sideset_enable
when creating the rp2pio.StateMachine object.Fixes #16 and fixes #21.
This needs https://github.com/adafruit/circuitpython/pull/5766