File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2021 Jeff Epler, written for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: MIT
4+ #
5+ # Adapted from the example https://github.com/raspberrypi/pico-examples/tree/master/pio/pio_blink
6+
7+ import adafruit_pioasm
8+ import board
9+ import array
10+ import rp2pio
11+ import time
12+
13+ blink = adafruit_pioasm .assemble (
14+ """
15+ .program blink
16+ pull block ; These two instructions take the blink duration
17+ out y, 32 ; and store it in y
18+ forever:
19+ mov x, y
20+ set pins, 1 ; Turn LED on
21+ lp1:
22+ jmp x-- lp1 ; Delay for (x + 1) cycles, x is a 32 bit number
23+ mov x, y
24+ set pins, 0 ; Turn LED off
25+ lp2:
26+ jmp x-- lp2 ; Delay for the same number of cycles again
27+ jmp forever ; Blink forever!
28+ """
29+ )
30+
31+
32+ while True :
33+ for freq in [5 , 8 , 30 ]:
34+ with rp2pio .StateMachine (
35+ blink ,
36+ frequency = 125_000_000 ,
37+ first_set_pin = board .LED ,
38+ wait_for_txstall = False ,
39+ ) as sm :
40+ data = array .array ("I" , [sm .frequency // freq ])
41+ sm .write (data )
42+ time .sleep (3 )
43+ time .sleep (0.5 )
You can’t perform that action at this time.
0 commit comments