Shop OBEX P1 Docs P2 Docs Learn Events
Onchip programming? — Parallax Forums

Onchip programming?

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

  • cgraceycgracey Posts: 14,133

    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.

  • RaymanRayman Posts: 13,897
    edited 2021-02-09 01:44

    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/

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2021-02-09 04:25

    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:

    -------------------------------------------------------------------------------
      Parallax P2  .:.:--TAQOZ--:.:.  V1.1--v33h         190219-1900
    -------------------------------------------------------------------------------
    TAQOZ# pub fibo ( n -- f )               0 1 ROT FOR BOUNDS NEXT DROP ; ---  ok
    TAQOZ# 46 fibo . --- 1836311903 ok
    TAQOZ# 1 46 ADO CRLF I . 3 SPACES I fibo . LOOP --- 
    1   1
    2   1
    3   2
    4   3
    5   5
    6   8
    7   13
    8   21
    9   34
    10   55
    11   89
    12   144
    13   233
    14   377
    15   610
    16   987
    17   1597
    18   2584
    19   4181
    20   6765
    21   10946
    22   17711
    23   28657
    24   46368
    25   75025
    26   121393
    27   196418
    28   317811
    29   514229
    30   832040
    31   1346269
    32   2178309
    33   3524578
    34   5702887
    35   9227465
    36   14930352
    37   24157817
    38   39088169
    39   63245986
    40   102334155
    41   165580141
    42   267914296
    43   433494437
    44   701408733
    45   1134903170
    46   1836311903 ok
    TAQOZ# 
    

    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.

  • Cluso99Cluso99 Posts: 18,069

    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.

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2021-02-10 08:46

    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 :) )

    10 FOR I = 1 TO 10
    20 PRINT I; PRINT" SQUARED = ";
    30 PRINT I*I
    40 NEXT I
    

    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.

    TAQOZ# 1 10 ADO CRLF I .AS" ##\ SQUARED IS = " I I * PRINT LOOP --- 
     1 SQUARED IS = 1
     2 SQUARED IS = 4
     3 SQUARED IS = 9
     4 SQUARED IS = 16
     5 SQUARED IS = 25
     6 SQUARED IS = 36
     7 SQUARED IS = 49
     8 SQUARED IS = 64
     9 SQUARED IS = 81
    10 SQUARED IS = 100 ok
    

    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
    ;)

  • @Mickster said:
    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.

  • @Mickster said:
    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.

    TAQOZ# 320,000,000 clkfreq! ---  ok
    TAQOZ# 1,000,000 lap for next lap .lap --- 32,000,082 cycles= 100,000,256ns @320MHz ok 
    

    That's 10M/sec on one core alone!.

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2021-02-11 00:51

    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.

    TAQOZ# DIRW --- 
    P2 CARD    
    _BOOT_P2.BIX  [BMP    ]     [BMV    ]     [FTH    ]     [HTM    ]     [PDF    ]     
    [PNG    ]     [TXT    ]     [WAV    ]     _BOOT_P2.LZ4  FAVICON.ICO   IMAGE         
    IMAGE1        IMAGE2        IMAGE3        P8CPU.JPG     SPIDEY.GIF    TIGER.GIF     
    TIGER.JPG     FISH2.VT      RAM.BIN       EYEGOD.BMP    WINDOWS.WAV   MINION.BMP    
    TAQOZ.WAV     TAQOZUP.WAV   BOOT.CFG      TEST          SCREEN         ok
    TAQOZ# PLAY TAQOZ ---  ok
    TAQOZ# 1,000,000 LAP FOR NEXT LAP .LAP --- 32,000,089 cycles= 160,000,445ns @200MHz ok
    TAQOZ# fibos --- 
    fibo(1) = 449 cycles= 2,245ns @200MHz result = 1
    fibo(6) = 769 cycles= 3,845ns @200MHz result = 8
    fibo(11) = 1,089 cycles= 5,445ns @200MHz result = 89
    fibo(16) = 1,409 cycles= 7,045ns @200MHz result = 987
    fibo(21) = 1,729 cycles= 8,645ns @200MHz result = 10,946
    fibo(26) = 2,049 cycles= 10,245ns @200MHz result = 121,393
    fibo(31) = 2,369 cycles= 11,845ns @200MHz result = 1,346,269
    fibo(36) = 2,689 cycles= 13,445ns @200MHz result = 14,930,352
    fibo(41) = 3,009 cycles= 15,045ns @200MHz result = 165,580,141
    fibo(46) = 3,329 cycles= 16,645ns @200MHz result = 1,836,311,903 ok
    
    
  • Congratulations you have passed the 10000 post.

  • @frida said:
    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.

Sign In or Register to comment.