Skip to content

Convert hello_interp.c:times_table to µPython #58

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions interp/interp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# demonstrate driving low level rp2040 functions from Python by
# direct register access - see datasheet at
# https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
# for details

from machine import mem32

# base address of SIO
SIO_BASE = 0xD0000000

# INTERP0 registers
INTERP0_ACCUM0 = SIO_BASE + 0x80
INTERP0_BASE0 = SIO_BASE + 0x88
INTERP0_POP_LANE0 = SIO_BASE + 0x94
INTERP0_CTRL_LANE0 = SIO_BASE + 0xAC

# initialise lane 0 on interp: set that we are using all 32 bits
mem32[INTERP0_CTRL_LANE0] = 0x1F << 10

# set up 9 x table example - write to accum[0] and base[0] registers
mem32[INTERP0_ACCUM0] = 0
mem32[INTERP0_BASE0] = 9

# read pop register 10 times
for j in range(10):
print(mem32[INTERP0_POP_LANE0])