Onchip programming?
RetroJeff
Posts: 15
in Propeller 2
I'm new to the P2, but I seem to remember that Chip Gracey intended to have some sort of on-chip programming environment incorporated in the new Propeller. Does this exist?
Comments
Not yet. This is something I really want to do, though.
TAQOZ is an on-chip programming environment built into the on-chip ROM (FORTH). I'm working on the P2 version of FemtoBasic for the P1. This is a simple integer-only Basic. I'm in the process of debugging some of the changes from the P1 to P2 versions like arrays and a Linux-like PRINT USING statement. This will take a couple of weeks and I'll continue to post updates as I get parts to work.
FemtoBasic looks neat. Appears to store programs in flash.
Good luck with it Mike!
I thought @"Mike Green" had a new thread on FemtoBasic, but can't find it now...
I'm curious as to whether something like Blockly could create code for FemtoBasic to run...
There's also self-hosted 'P2 Native MicroPython' that you can program on the chip, either by serial terminal, or usb keyboard + vga monitor
https://www.parallax.com/propeller-2/get-started/micropython/
If after reset you connect with a serial terminal and type the two autobaud characters [>] and [space] then hit [Esc] it will come up with TAQOZ in ROM. You can construct whole applications or simply play with the smart pins etc. Type WORDS to list all the predefined functions which you can then add to, like in this terminal capture:
BTW, the reason TAQOZ was included in ROM was because it was available and it was useful and it could fit into 12kB. It can be used simply as a hardware and sanity checker since it only uses RCFAST (~25MHz) and is not dependent on external devices or timing etc. As long as the power is mostly right, it will run.
TAQOZ and the monitor/debugger in ROM makes for almost instant checking on a minimal new P2. Only the serial pins 63 & 62 need to be connected to get a response from the P2 where you can check I/O pins, check SD, check Flash, etc, etc. Great for bringing up a new P2 board, or in fact any production board too. It's how I initially check my RetroBlade2 boards.
The early microcomputers came with BASIC in ROM which was fun because it was interactive, but slow because it was BASIC in ROM.
TAQOZ is not BASIC, it's based on Forth but more specific to embedded micros than Forth itself.
Compare a simple BASIC program I might have typed into one of these micros. (EDIT: maybe line 20 needs to be two lines )
If I got that right then when we type RUN it would hopefully print out 10 lines of "n SQUARED = x" type of thing.
But I can type this in as one line in TAQOZ that temporarily compiles and executes as soon as I hit enter as this terminal capture shows.
But if I wanted to create a new word that did this, all I need to do is "name" it like this:
: SQUARES 1 10 ADO CRLF I .AS" ##\ SQUARED IS = " I I * PRINT LOOP ;
When I type SQUARES it executes or I can use squares within another new word as well etc.
But is it fast? The actual calculation of the square of the current loop index I takes 210 cycles which at 200MHz is around 1us.
But now have some fun and type in this one-liner
pub TONES ( pin -- ) PIN 3000 100 DO I HZ 50 ms 100 +LOOP MUTE ;
Then hook up a speaker to pin 32 for instance and type `32 TONES' and listen.
One line? No problem:
For I = 1 to 10:? I;“ SQUARED = ";I*I:Next
That variant of BASIC didn't work on my PC BASIC but the real difference is that you are compiling it on a PC and downloading the runtime onto the P2.
TAQOZ though is on-chip in 12k of ROM and it is interactive and it is fast and you can develop complete applications with it.
Yeah, I love the TAQOZ concept 👍
I have only just received my fist P2 and I need to grab a KISS module but I need to block out some time.
I also use the no-longer-developing ByPIC language which resides on the PIC32MX170. It's a mixture of c and basic and the implementation was inspired by Forth. One can write functions and immediately execute them from the command prompt. Unlike other on-chip BASICs, this thing can run up to 20 tasks and the command prompt remains active.
Pretty cool, an empty for/next loops @ 1.2M/sec on a 40MHz chip.
By way comparison this is the timing for 1,000,000 empty FOR/NEXT loops
TAQOZ# 1,000,000 lap for next lap .lap --- 32,000,082 cycles= 160,000,410ns @200MHz ok
Then even though the P2 requires 2 clocks per instruction, still at 40MHz clock it takes 800ns or 1.25M/sec (of course at 320MHz....
TAQOZ# 1,000,000,000 160 5 * / . --- 1250000 ok
Of course the P2 has 8 cores and is not slowed down by the need for interrupts and can run much faster.
That's 10M/sec on one core alone!.
That's the beauty of the P2, the multiple cores and no need for interrupts etc. The timing of these tests doesn't skip a beat even while it is outputting VGA, and playing a 44.1kHz wave file. Immediately after starting to play a file I ran my FOR NEXT timing etc and they are as we expect them to be on a P2, exactly the same. Let's see any other MCU or even the Pi do that and guarantee timing.
Congratulations you have passed the 10000 post.
Well well so I have. But I may add a lot more to that after I post compact and interactive TAQOZ code for this:
It almost seems too easy.