Move micropython UF2 to Pico following directions on Getting Started download Thonny in Thonny: Tools > Options > Interpreter Tab Choose generic micropython Choose USB serial device (with appropriate device name) ================================== In edit pane: Paste in: from machine import Pin, Timer led=Pin(25,Pin.OUT) tim=Timer() def tick(timer): led.toggle() tim.init(freq=2.5,mode=Timer.PERIODIC,callback=tick) Run current script LED should blink runs at 10KHz, fails at 100KHz and HANGS the system have to unplug/plug to restart ================================== from machine import Pin, Timer led=Pin(15,Pin.OUT) x=0 while (x<300000): led.toggle() x += 1 produces 24.6 KHz square wave with around 5% jitter => loop at ~50 KHz ================================== import time from rp2 import PIO, asm_pio from machine import Pin # Define the blink program. It has one GPIO to bind to on the set instruction, which is an output pin. # Use lots of delays to make the blinking visible by eye. @asm_pio(set_init=rp2.PIO.OUT_LOW) def blink(): wrap_target() set(pins, 1) [1] set(pins, 0) [1] wrap() # Instantiate a state machine with the blink program, at 1000Hz, with set bound to Pin(15) sm = rp2.StateMachine(0, blink, freq=100000000, set_base=Pin(15)) # Run the state machine for 3 seconds. The LED should blink. sm.active(1) time.sleep(3) sm.active(0) Clock rate 100MHz, toggles i/o pin at 25 Mhz Deleting the [1] delays bumps the toggle rate to 50 MHz! ============================================ Thonny can save a script directly to the MCU flash drive and can erase a file. If you save test.py, then at the command line type: import test starts it running Typing: tim.deinit() stops the timer-triggered routine cntl-d also stops it ================================== Choosing Tools>Open system shell opens a console directly to the >>> prompt (which is also at the bottom of the Thonny window) Typing a CNTL-d does a soft reset Typng help('modules') gives a list of modules >>> help('modules') __main__ framebuf uasyncio/__init__ uio _boot gc uasyncio/core uos _onewire machine uasyncio/event urandom _rp2 math uasyncio/funcs uselect _thread micropython uasyncio/lock ustruct _uasyncio onewire uasyncio/stream usys builtins rp2 ubinascii utime ds18x20 uarray ucollections Typing help(module) gives contents of the module BUT you need to import it first! ======================================= >>> help(machine) object is of type module __name__ -- umachine reset -- reset_cause -- bootloader -- freq -- mem8 -- <8-bit memory> mem16 -- <16-bit memory> mem32 -- <32-bit memory> ADC -- I2C -- SoftI2C -- Pin -- PWM -- SPI -- SoftSPI -- Timer -- UART -- WDT -- PWRON_RESET -- 1 WDT_RESET -- 3 what is mem8, mem16, mem32? Mostly useful for read/write control registers read: machine.mem32[address] write: machine.mem32[address] = number === Generate address of an array ================ Assembler reference https://docs.micropython.org/en/latest/reference/asm_thumb2_index.html a=array.array('b',[ 1, 2, 3]) @micropython.asm_thumb # passing an array name to the assembler # actually passes in the address def addressof(r0): # r0 is the output register mov(r0, r0) addr_a = addressof(a) print(addr_a) print(machine.mem8[addressof(a)]) ================== a=array.array('i',[ 1, 2, 3]) @micropython.asm_thumb def addressof(r0): mov(r0, r0) addr_a = addressof(a) print(addr_a) print(machine.mem32[addressof(a)+4]) #prints '2' ================================================= >>> help (builtins) object is of type module __name__ -- builtins __build_class__ -- __import__ -- __repl_print__ -- bool -- bytes -- bytearray -- complex -- dict -- enumerate -- filter -- float -- int -- list -- map -- memoryview -- object -- property -- range -- reversed -- set -- slice -- str -- super -- tuple -- type -- zip -- classmethod -- staticmethod -- Ellipsis -- Ellipsis abs -- all -- any -- bin -- callable -- chr -- delattr -- dir -- divmod -- eval -- exec -- getattr -- setattr -- globals -- hasattr -- hash -- help -- hex -- id -- input -- isinstance -- issubclass -- iter -- len -- locals -- max -- min -- next -- oct -- ord -- pow -- print -- repr -- round -- sorted -- sum -- BaseException -- ArithmeticError -- AssertionError -- AttributeError -- EOFError -- Exception -- GeneratorExit -- ImportError -- IndentationError -- IndexError -- KeyboardInterrupt -- KeyError -- LookupError -- MemoryError -- NameError -- NotImplementedError -- OSError -- OverflowError -- RuntimeError -- StopAsyncIteration -- StopIteration -- SyntaxError -- SystemExit -- TypeError -- ValueError -- ViperTypeError -- ZeroDivisionError -- open -- ================================================= Does @micropython.asm_thumb work?