Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import adafruit_pioasm
- import rp2pio
- import time
- import array
- import board
- counter = """
- .side_set 1 opt
- set y, 0
- mov y, !y
- in y,32 ; just to calm circuitpython: "RuntimeError: No in in program"
- .wrap_target
- loop:
- wait 1 pin 0 side 0
- wait 0 pin 0 side 1
- jmp y-- loop
- """
- in_str = """
- in y, 32
- """
- asm = adafruit_pioasm.assemble(counter)
- in_asm = adafruit_pioasm.assemble(in_str)
- sm = rp2pio.StateMachine(
- program=asm,
- frequency=125000000,
- first_sideset_pin=board.LED,
- sideset_enable=True,
- #INPUT
- first_in_pin=board.GP0,
- in_pin_count=1,
- pull_in_pin_up=1,
- auto_push=True,
- wrap_target = 3
- )
- for i in range(10):
- sm.run(in_asm)
- #while sm.in_waiting: #WTF? sm.in_waiting is allways 8 !!
- if True:
- print(sm.in_waiting, end=" ")
- buffer = array.array('L', [0])
- sm.readinto(buffer)
- print(buffer)
- time.sleep(1)
- time.sleep(50)
Add Comment
Please, Sign In to add comment