Someone really needs to raise a feature request to have the MicroPython PIO Assembler made more robust, have it error on incorrect use of PIO instructions - Using 'mov' where 'set' should have been used, not reporting the 'set' value is out of range, are the most common mistakes which the Assembler lets through.I don't know what happens when you compile this, but you've used some instructions that don't exist - mov(x, 31250000). The MOV instruction can only move values between registers, it can't load an immediate value. The one instruction that can load an immediate value is SET, but that's restructed to 5 bits (ie. 0..31).
Unfortunately there's no robust error checking. The Assembler converts register names to integer values, masks for field size if lucky, uses them whether valid or not, or maybe just corrupts the intended instruction.
A report on a value being too large for the field would help a lot but it won't identify issues like 'set(isr, 0)'.
Doing it properly, making it robust, can be done. It's fairly easy but also a fair amount of work. At the very least it requires changing named registers from being simple integer aliases to a class of named 'register type' then checking the parameters are correct and valid for each instruction -
Code:
pioasm.PIOASM_Error: @asm_pio def Test(): 1 : mov(x, 0x1DCD650) ^ Source register expected - Got '0x1DCD650' (31250000)
Code:
pioasm.PIOASM_Error: @asm_pio def Test(): 1 : set(x, 0x1DCD650) ^ Set value 31250000 is not in range -1 to 31
It is possible to construct any arbitrary number constant in PIO code but it usually eats up too many instructions to make it practical and there are other issues as well. Just push the number in when the code starts, use a register to hold it. Unfortunately registers which can be used are rather limited in number.
Statistics: Posted by hippy — Sat Aug 03, 2024 6:12 pm