Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:05 13 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PIO Assembler

Author Message
ville56
Senior Member

Joined: 08/06/2022
Location: Austria
Posts: 221
Posted: 02:18pm 26 Nov 2024
Copy link to clipboard 
Print this post

I want to dive a bit into the PIO stuff and thus was trying out some of the examples from the WebMite manual. Some basic things work but i cannot get the instruction

PIO ASSEMBLE 1,"SET PIN 1"

to work. I receive a syntax error. Is there any current documentation on the pio assembler available? I found Vollhout's excellent post "PIO explained" but i want to use the mnemonics wherever possible.

Thanks,
Gerald
                                                                 
73 de OE1HGA, Gerald
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5059
Posted: 02:39pm 26 Nov 2024
Copy link to clipboard 
Print this post

Hi Gerald,

The correct syntax is:

PIO ASSEMBLE 1,"SET PINS,1"


So it is PINS
And it needs a comma to separate the value.

Volhout

P.S. At the beginning of the sequel "PIO explained" there was no build in assembler yet in PicoMite. So it is very well possible that the menomics where inaccurately written.
Edited 2024-11-27 00:42 by Volhout
PicomiteVGA PETSCII ROBOTS
 
ville56
Senior Member

Joined: 08/06/2022
Location: Austria
Posts: 221
Posted: 02:53pm 26 Nov 2024
Copy link to clipboard 
Print this post

Many thanks Vollhout,

but where did you get this information from? I could not find this.

Gerald
                                                                 
73 de OE1HGA, Gerald
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10246
Posted: 03:06pm 26 Nov 2024
Copy link to clipboard 
Print this post

https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf
 
ville56
Senior Member

Joined: 08/06/2022
Location: Austria
Posts: 221
Posted: 03:11pm 26 Nov 2024
Copy link to clipboard 
Print this post

Ahhh, now i see .... thanks

Gerald
                                                                 
73 de OE1HGA, Gerald
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5059
Posted: 03:15pm 26 Nov 2024
Copy link to clipboard 
Print this post

Hi Gerald,

Honestly...try and error...
Your program should look like this.


PIO ASSEMBLE 1,".program anyname"
PIO ASSEMBLE 1,".list 1"

// here comes your program

PIO ASSEMBLE 1,".end program list"


if you want to assemble instructions, just add them in the section // here comes the program

When you RUN the program, there are 2 possibilities:

1/ you get a list of PIO codes, and then the prompt (the end of the program). That is succesfull compiled.

2/ you get some PIO codes, and then an error message. That is the instruction that fails. Then you try with either adding a comma, or brackets, or whatever, until it compiles correct.

But as a guide you can look at chapter 3 of the RP2040 datasheet, where the menmonics are explained. Note that the mnemonic syntax change when you configure the PIO different (i.e. using delay/sideset in some balance). So you may have to experiment a bit.

I guess the PIO compiler is taken from RP's source, so there may be a good description of the mnemonics on their website. But I did not find it. I just used the datasheet, and try-and-error. I knew that the datasheet specifies "PINS" and not "PIN" for the field in the SET instruction (I did a lot of reading in the datasheet, and luckily I remembered).


Volhout

Volhout
Edited 2024-11-27 01:17 by Volhout
PicomiteVGA PETSCII ROBOTS
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1361
Posted: 03:50pm 26 Nov 2024
Copy link to clipboard 
Print this post

Some good PIO examples
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7871
Posted: 03:54pm 26 Nov 2024
Copy link to clipboard 
Print this post

The mnemonics are crazy... :)  There aren't many *instructions* but the number of slight variations on many of them can get ridiculous. lol
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
ville56
Senior Member

Joined: 08/06/2022
Location: Austria
Posts: 221
Posted: 04:09pm 26 Nov 2024
Copy link to clipboard 
Print this post

Thanks to all for the help. This forum is really living how to help each other. Fantastic work ....

and yes, i'm now carefully reading the PIO section in the datasheet, trying to understand .... the first tiny program already runs.

Gerald
                                                                 
73 de OE1HGA, Gerald
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5059
Posted: 08:28pm 26 Nov 2024
Copy link to clipboard 
Print this post

Hi Phenix,

The issue is that the PIO mnemonics do not follow a logical pattern, hence the try and error.

in example:

SET PINS,1

requires a comma between PINS and 1

JMP X-- 1

where 1 is an address to JMP to under condition X=0, post decrement X does not accept a comma between X-- and 1

OUT PINS,1 SIDE 1

Requires 1 comma for PINS, but no comma for the SIDE and 1

OUT PINS,1 [2]

Uses brackets to indicate a delay of 2 clocks in the command. That is deviating from the written text like SIDE. On the other hand, you can't go wrong with that one...

Feels a bit like "put together as we go" in stead of a logical syntax.

Volhout

P.S. Gerald, if you look at python examples for PIO, the assembly mnemonics should 1:1 work in MMBasic. Completely different is the python configuration of the PIO's. For that you better look at the user manual of MMBasic. Python may only confuse you.
Note that the EXECCTRL, PINCTRL helper functions in MMBasic just fill in bits in the EXECCTRL and PINCTRL registers that can be found in the RP2040 datasheet in the PIO register map. And there they are explained quite good. Go to the register map, and browse until you find the register you are interested in.
Edited 2024-11-27 06:36 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7871
Posted: 08:35pm 26 Nov 2024
Copy link to clipboard 
Print this post

It really did my head in....   lol
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025