JetBrains / intellij-micropython

Plugin for MicroPython devices in PyCharm and IntelliJ
https://plugins.jetbrains.com/plugin/9777-micropython
Apache License 2.0
514 stars 107 forks source link

RP2: PIO commands in a python file are flagged as "Unresolved reference" errors #237

Open sandyscott opened 1 year ago

sandyscott commented 1 year ago

If you have a PIO program assembled in a python file, all of the instuctions are flagged as "Unresolved reference" errors.

import rp2

@rp2.asm_pio()
def quadrature_encoder():
    jmp("label1")
    nop()
    label("label1")

appears as image

This issue applies to all instructions and directives appearing the program.

The full list of instructions and directives is visible in the official documentation: Programmable IO - MicroPython latest documentation

fiechr commented 1 year ago

I'm having the same issue.

Example:

from machine import Pin
from rp2 import PIO, StateMachine, asm_pio
from time import sleep

@asm_pio(sideset_init=PIO.OUT_LOW)
def pwm_prog():
    pull(noblock) .side(0)
    mov(x, osr) # Keep most recent pull data stashed in X, for recycling by noblock
    mov(y, isr) # ISR must be preloaded with PWM count max
    label("pwmloop")
    jmp(x_not_y, "skip")
    nop()         .side(1)
    label("skip")
    jmp(y_dec, "pwmloop")

pycharm_20230604_072710

There are other error hints as well. It seems to me, that maybe the bundled µPython isn't the latest version? Can this be changed by the user? For example the class StateMachine doesn't have a exec() method, although in newer version it seems to have it, since the code runs completely fine when just flashing it to the RP2040.