2023-01-06 17:55:02 +00:00
|
|
|
# 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
|
|
|
|
|
2023-01-06 14:01:06 +00:00
|
|
|
from machine import mem32
|
|
|
|
|
2023-01-06 17:55:02 +00:00
|
|
|
# base address of SIO
|
|
|
|
SIO_BASE = 0xD0000000
|
|
|
|
|
|
|
|
# INTERP0 registers
|
2023-01-06 18:31:42 +00:00
|
|
|
INTERP0_ACCUM0 = SIO_BASE + 0x80
|
|
|
|
INTERP0_BASE0 = SIO_BASE + 0x88
|
|
|
|
INTERP0_POP_LANE0 = SIO_BASE + 0x94
|
|
|
|
INTERP0_CTRL_LANE0 = SIO_BASE + 0xAC
|
2023-01-06 17:55:02 +00:00
|
|
|
|
2023-01-06 14:01:06 +00:00
|
|
|
# initialise lane 0 on interp: set that we are using all 32 bits
|
2023-01-06 17:55:02 +00:00
|
|
|
mem32[INTERP0_CTRL_LANE0] = 0x1F << 10
|
2023-01-06 14:01:06 +00:00
|
|
|
|
|
|
|
# set up 9 x table example - write to accum[0] and base[0] registers
|
2023-01-06 17:55:02 +00:00
|
|
|
mem32[INTERP0_ACCUM0] = 0
|
|
|
|
mem32[INTERP0_BASE0] = 9
|
2023-01-06 14:01:06 +00:00
|
|
|
|
|
|
|
# read pop register 10 times
|
|
|
|
for j in range(10):
|
2023-01-06 17:55:02 +00:00
|
|
|
print(mem32[INTERP0_POP_LANE0])
|