Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 22:51 16 May 2024 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 : PicoMite PASM

Author Message
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5768
Posted: 06:10pm 22 Dec 2021
Copy link to clipboard 
Print this post

PASM seems to have got a bit lost on the forum now, so here's a re-post for anyone who might still be interested. I think these are the last versions that I had working, so they may include the little file handling system to read and write to a SDcard.

PASM:   PASM12a.zip
PREVAS: PREVAS 011.zip
 
Warning - I've not looked at this code for some time so I'm a bit fuzzy about it. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 07:28pm 22 Dec 2021
Copy link to clipboard 
Print this post

Hey Mick,

I am sure that this should be of great interest to me BUT I still don't have a grasp on what it does. Can I control a process with it, independent of what MMBasic is doing....like a separate high-speed task?

Apologies for being dumb but I'm currently burning the candle at both ends on another project.

-Craig
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5768
Posted: 11:00pm 22 Dec 2021
Copy link to clipboard 
Print this post

In a word, yes. "How" is a different word and it gets very complicated. :)

A PIO has 32 bytes of 4-read port memory space all to itself, it also has 4 state machines that all share that memory. The state machines run independently of everything at a clock speed divided down from the system clock - they can all be running at different speeds if you like. Each one can handle some IO pins. They can be running from the same area of memory or different areas of it. Data can be "squirted" both ways to and from the main system under interrupt control. Unless you specifically put some code in to interact with a state machine MMBasic doesn't know it's there.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 07:12am 23 Dec 2021
Copy link to clipboard 
Print this post

Can I read a SPI device and can I generate a PWM?

One thing that I don't get with MMBasic is that, no matter what frequency, we have a fixed range of 1000 (0.1%).

Why can't we have say 125MHz/4096 (12bit resolution) @ ~15KHz?
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5768
Posted: 08:19am 23 Dec 2021
Copy link to clipboard 
Print this post

The RP2040 Datasheet has examples of a PIO being used for Duplex SPI and for PWM (no, I don't understand them!   ). (Note that PIO0 is already used on the PicoMite VGA so that only has PIO1 available to the user.)

As to the limits, I just don't know. I could only guess.

Not much help this morning, am I? :)


The state machines, although pretty sophisticated in their own way, are actually pretty dim. They aren't CPU cores, but are optimised to run tight repetitive tasks fast. They don't see things like system interrupts (only their own) so they can accurately produce and handle timing sequences down to a single clock cycle.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 09:04am 23 Dec 2021
Copy link to clipboard 
Print this post

Not much help? Au contraire. This is exciting stuff  
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3585
Posted: 09:37am 23 Dec 2021
Copy link to clipboard 
Print this post

@Tinine,

The PIO sequencer in pico is great because it can do IO related tasks autonomously.
One of these things could be the 12bit PWM. I am sure the PIO can do that. Actually, that is something that matches the PicoMite nicely. Why....

The PIO sequencer has split program memory and data memory. You write a program in the program memory and pass data to it through the data memory. The data memory is a 32bit register to pass data to it (one for input, one for output). That is you connection with the ARM processor.

PWM is something that you set a value, and it runs autonomously. Only when you write a 32 bit value new value it changes.
Same as SPI. Only under control of MMBasic something happens (unless you are SPI slave). You pass xxx 32 bit values in sequence and it sends it out.
So the ARM passes data to the 32bit register, and the PIO takes care it get's processed. Then signals the ARM it can accept new data.

Some tasks are really ARM intense. Like creating video. The ARM has to provide the video data to the PIO block (either through DMA or directly), and when it is time critical, it has to respond fast. That interferes with MMBasic, response is needed so fast, basic cannot do that.

That is why the VGA PicoMite uses the second ARM core in the RP2040 for video generation.

For the PicoMite. Peter also suggested to use the second ARM core for PIO support, maybe through CSUB's. In that case real time PIO actions would not interfere with MMBasic.

I am sure Peter would be able to implement that functionality, but no-one has requested it, or explained why we need it. Maybe you are the first one.
Again, this is not needed for PWM, and probably also not for SPI, since these are controlled from MMBasic anyway. The second core would be needed if you really have a fast process that runs autonomously. You could think of a "logic analyzer" that reads 8 or 16 bit of data with xx Mhz sample rate, and stores it in RAM. But 60k RAM is not a lot for that application.
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8603
Posted: 10:04am 23 Dec 2021
Copy link to clipboard 
Print this post

  Quote  One thing that I don't get with MMBasic is that, no matter what frequency, we have a fixed range of 1000 (0.1%).


Not in my ports, you have accuracy dependent on the frequency of up to 1 in 65536 (16-bit timer). Accuracy will reduce above a frequency of system clock/65536 so that at system clock/2 you can have 0, 50% or 100% only. Below system clock/65536 the PWM master clock is divided by 2 as few times as possible to give the maximum accuracy possible for any given frequency

Note: This affects both frequency accuracy and duty cycle accuracy
Edited 2021-12-23 20:15 by matherp
 
flasherror
Senior Member

Joined: 07/01/2019
Location: United States
Posts: 159
Posted: 11:16pm 05 Jan 2022
Copy link to clipboard 
Print this post

How bug-free (no offense intended) is PASM at this point? I want to try experimenting with PIO programming and it seems the options are either use micropython/circuitpython (since they have PIO support) or PASM/PREVAS.

Those who have done PIO stuff, what have you used to learn?
The latest Picomite manual at time of writing this is PicoMite_User_Manual 5.07.01 and the PIO section worries me with the "[currently in the development & testing stage]".
Edited 2022-01-06 09:20 by flasherror
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5768
Posted: 07:53am 06 Jan 2022
Copy link to clipboard 
Print this post

I've never actually attempted PIO programming, but I can comment on PASM and PREVAS. :)

Within its limitations and for simple applications you should be ok with PASM. I tested it with quite a lot of random samples and it came up with the correct (or explainable) code. However, it doesn't deal with edge cases and complex stuff - it simply isn't clever enough. It should be used in conjunction with the PIO support now built into MMBasic.

You DO need to read (and preferably understand!) the section of the RP2040 Datasheet on PIO operation though. PASM doesn't hold your hand in any way, it's only a crude assembler to do some of the donkey work for you. At the end of the day you can only have 32 instructions in a PIO so you never have to deal with big blocks of code.

PREVAS is even cruder. It takes the assembled code and takes a blind guess at the instructions that assembled it. A couple of things are spotted, but it can't tell if you have, for example, used some memory space as constants. It will simply disassemble them as instructions. It's still a useful tool though, to give you a check on your code.

TBH I'm not sure if either will ever be out of "the development & testing stage". lol  When I wrote that section of the manual I was still getting a couple of minor bugs out of PASM, but it was usable. I'm not making any claim that it's bug-free, in fact I suspect there are a load of nasties still in there for you to find and have fun with. :)  I've never written an assembler before (or since) so I don't know what I've missed. :)
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.

© JAQ Software 2024