P2 Newbie Discussion

in Propeller 2
So that we don't mess up the official "P2-ES Board Support" Discussion at forums.parallax.com/discussion/169367/p2-es-board-support#latest I am am starting this discussion, where Us P2 Newbies can share info and come up to speed on the P2.
I wish to thank Chip, Parallax and those "smart" users/developers (you know who you are) that have made the P2 a reality!!!
I will start things off, with a copy of my post from the "P2-ES Board Support" Discussion.
I wish to thank Chip, Parallax and those "smart" users/developers (you know who you are) that have made the P2 a reality!!!
I will start things off, with a copy of my post from the "P2-ES Board Support" Discussion.
Eric,
Thanks for the link to "spin2gui". I have downloaded and installed it. I am anxiously awaiting for my P2-ES board.
Regards, zappman
Comments
I'll go first - I'm unable to get any of the code in spin2gui/samples to actually run - not even helloworld. The binaries appear to load but nothing appears out the serial pins and even trying to just bring a pin high and low does nothing. I'm using the latest spin2cpp files as well. TAQOZ does run fine and I'm positive I have a good USB cable feeding the P2-ES board. Perhaps the sample code is configured somehow for the FPGAs and things are inoperative due to that? I've looked at the generated .asm and .lst files and nothing jumps out at me. The pin designation for tx is correct, etc. Ideas are appreciated!
Thanks, Mike R...
To start with the P2 now, you will pretty much need to learn/use P2 assembler, or learn/run TAQOZ. That does not mean you will need to learn all the assembler opcodes. Heck I don't even understand many of them, and I have to check regularly.
So, I am going to suggest two routes...
TAQOZ
No assembler required. Use TAQOZ and just use one-liners. Peter has an extension that can be loaded into FLASH (or SD?) that can then easily be added into TAQOZ which allows lots of extra TAQOZ features.
P2ASM
I am going to suggest unless you are experienced, I suggest you use P2ASM as the assembler because it gives a nice listing. PNUT is more for experienced programmers - it is the "bible" for P2 assembly but for you, P2ASM will be more friendly.
Editing source for P2ASM or PNUT in Win10
I use PropTool because I like the color interface, and highlit words. Use the extension ".spin" but just be careful not to confuse with P1 .spin code. Obviously not all P2 opcodes are recognised, but it does make life easier. Otherwise, use your favourite editor. When you are done editing, save your work with Ctl-S !!!!! You can leave the file open.
Compile with P2ASM.EXE
Edit a ".bat" file with Notepad to compile your .spin program. Here is an example.
p2asm ClusoInterpreterP2_301f.spin
Tip: Make sure P2ASM.exe, the .BAT file and your .SPIN files are in the same directory.To compile, just double-click the .bat file in Windows File Explorer.
P2ASM creates two files, a .BIN which is the code to download, and a .LST which is the listing file. You can view this in any editor. I use NotePad++.
Download your .bin file
Need some help here guys? Where is P2Load up to and a link???
Compile with PNUT.EXE
Open your .spin file (make sure you do this each time you edit your source) and compile and download.
DO NOT EDIT your code with PNUT. You have your source open in PropTool for this.
Boot from SD
Alternately, copy your .BIN file as "_BOOT_P2.BIX" (case sensitive) to a microSD card formatted as FAT32, and boot your P2 from that.
PST Propeller Serial Terminal
I use PST as my W10 terminal program. It's not the greatest but it works. Have it open and after downloading, quickly select it and click enable and you are good to go.
Obviously there are other ways to do this. I find this simple.
Here is a link where the ROM Monitor/Debugger etc are discussed
forums.parallax.com/discussion/168502/p2-rom-booter-serial-flash-sd-card-monitor-and-taqoz-features-and-operation/p1
Here is an example of calling/using the serial monitor ROM from your P2ASM code
forums.parallax.com/discussion/comment/1450717/#Comment_1450717
I was was able to power-up my board, before seeing any posts in this thread.
I had the same results as "pmrobert" when trying to use "spin2gui".
However, I was able to use "TAQOZ" via the "Parallax Serial Terminal" program to send commands to my P2-ES board, and blink the on-board LEDs at different rates. :cool:
@Cluso99 and the other above posters, thank you for your posts, helping us "P2 Newbies". :thumb:
forums.parallax.com/discussion/169465/parallax-p2-eval-p2es-chip-pcb-demo-code#latest
https://github.com/totalspectrum/spin2gui
Latest release is here - https://github.com/totalspectrum/spin2gui/releases
For new people I suppose it's important to note Chip is still working on the official reference implementation of Spin2.
Cold start ---------------------------------------------------------------- Parallax P2 .:.:--TAQOZ--:.:. V1.0--142 180530-0135 ---------------------------------------------------------------- TAQOZ# 56 blink ok TAQOZ# 1 blink ok TAQOZ# 2 blink ok TAQOZ# 3 blink ok TAQOZ# 4 blink ok TAQOZ# 2 pin 5 hz ok TAQOZ# 4 pin 10 hz ok TAQOZ# 57 blink ok TAQOZ# 57 pin 4 hz ok TAQOZ# 4 0 do i pin i 2 + hz loop ok TAQOZ#
Thanks Peter for an easy to use environment.
Tom
BEGIN 58 HIGH 100 ms 58 LOW 100 ms AGAIN
It's just an endless loop which you could also assign another cog to run in the backgroundHas anybody checked the Flash and SD?
.SF will print the SPI Flash IDs
MOUNT will mount a FAT32 card and report
DIR prints the directory
BACKUP saves any TAQOZ code you've loaded or created into Flash so that a ^R keystroke will restore everything when you boot up fresh into TAQOZ again. Do this after you pasted in TAQOZ EXTEND (it's the first link in my sig). These utilities allow you to change the clock rate easily, just type CRUISE to shift up to 180MHz or TURBO FOR 240MHz etc.
Type WORDS (or use ^W) to list the dictionary.
To check the state of all the I/O pins type lsio
Use DUMP DUMPW DUMPL DUMPA DUMPAW to dump all kinds of memory (SD, Flash, or default hub) in standard byte/word/long/ASCII/ASCII wide format.
To list memory from 0 for $100:
0 $100 DUMP
After I MOUNT the card I can open the root directory and DUMP it as if it were RAM.TAQOZ# @ROOT FOPEN ok TAQOZ# 0 $80 SD DUMP 00000: 50 32 44 32 20 20 20 20 20 20 20 08 00 00 9A 80 'P2D2 .....' 00010: 82 4D 82 4D 00 00 9A 80 82 4D 00 00 00 00 00 00 '.M.M.....M......' 00020: 5F 42 4F 4F 54 5F 50 32 42 49 4E 20 00 00 B1 30 '_BOOT_P2BIN ...0' 00030: 82 4D 84 4D 00 00 B1 30 82 4D 03 00 00 00 02 00 '.M.M...0.M......' 00040: 5F 42 4F 4F 54 5F 50 32 42 49 41 20 00 00 B9 30 '_BOOT_P2BIA ...0' 00050: 82 4D 82 4D 00 00 B9 30 82 4D 23 00 00 00 08 00 '.M.M...0.M#.....' 00060: 5F 42 4F 4F 54 5F 50 32 42 49 42 20 00 00 C1 30 '_BOOT_P2BIB ...0' 00070: 82 4D 82 4D 00 00 C1 30 82 4D A3 00 00 00 04 00 '.M.M...0.M......' ok
A few of us proved that TAQOZ could load extensions from FLASH on the P2D2. No reason for it not to work on P2-EVAL. Currently there is a hardware fix that won't be necessary with the next ROM.
To blink P58 in software vs smart pin mode you can do this:
BEGIN 58 LOW 100 ms 58 HIGH 100 ms KEY UNTIL 58 HIGH
In the above line KEY UNTIL makes the LED keep blinking until you press any key on your keyboard sending a character to the "P2 EVAL Board", the final 58 HIGH on the above line turns 'off' LED P58..SF $EF70_1800 $DB59_3129_$E468_5835 ok
Mounting appears to work OK:TAQOZ# MOUNT .JTNCard C829_46B7 NO NAME 4k 7,583M ok
I get a scrambled directory for some reason. I just formatted this card with a fresh FAT32 format in Windows and put two short .txt files on it to test with. Maybe I need to uncheck 'quick format', or try the official SD Association SD Card Formatter program?TAQOZ# DIR .JTNCard C829_46B7 NO NAME 4k 7,583M insERK7Q.Str $FDAC_24B5 2014.11.13.13.58 1,953,391,981 12hasAtt.rib $07C3_CC4D 1980.03.07.13.51 825,314,126 QDomElem.ent $9F4C_9BED 2020.09.23.09.26 1,735,289,202 S2_ _ZNK.16Q $979C_6B1D 2036.03.01.09.43 1,684,368,737 ItemERK7.QSt $FDAC_24B5 2014.11.13.13.58 1,953,391,981 13attrib.ute $16BB_F155 2031.11.14.13.11 1,362,710,106 HashData.14d $9FA4_AB85 2020.02.05.06.19 1,599,295,056 4NodeEPv.EPF $E6F4_64CD 2014.02.17.07.01 1,819,307,337 ementati.on1 $1F3C_C3F5 2038.03.14.12.43 1,380,279,664
TAQOZ# MOUNT .JTNCard 56D0_AC41 NO NAME 4k 7,583M ok TAQOZ# DIR .JTNCard 56D0_AC41 NO NAME 4k 7,583M ok
Are there restrictions as far as file name that TAQOZ will see (all caps, have to be exactly 8.3, etc) or how I need to be formatting the SD card?I loaded the TACOZ-EXTEND.FTH, then used 'BACKUP', unplugged the board, plugged it back in, and restored with Ctrl-R from the TACOZ prompt. All the speed setting words from the backup work fine, so that is working well (all with the FLASH dip switch still at 'on' of course).
What size are the files ? - you could check if it is getting that bit right ?
You could try files like 1.1, 22.22, 333.333, 1234.TXT, 12345678.TXT, 1234567890.TXT of varying sizes and see what DIR looks like.
Make sure your filename is in capitals, up to 8 characters in length and only 3 characters for the extension (8.3).
Here's part of my directory dump in ASCII format using DUMPA. You can clearly see the 8.3 names as they look like a 11 character name with spaces to fill the gaps.
TAQOZ# 0 $400 SD DUMPA 00000: P2D2 ......M.M.....M......_BOOT_P2BIN ...0.M.M...0.M...... 00040: _BOOT_P2BIA ...0.M.M...0.M#....._BOOT_P2BIB ...0.M.M...0.M...... 00080: BEACH BMP ...0.M.M...DkM..Z...SPIDEY PNG ...0.M.M...j]M/..... 000C0: SPIDEY GIF ...0.M.M....]MN..8..SPIDEY BMP ...0.M.M...#\Mr.z... 00100: MCQUEEN BMP ...0.M.M..n"\M..z...EYEGOD BMP ...0.M.M..2"\M..z... 00140: SUNSET BMP ...0.M.M...!\MV.z...FACE BMP ...0.M.M..y \M..z... 00180: TIGER1 BMP ..[7.M.M..U7.M.=z0..TIGER GIF ...0.M.M....YM..t... 001C0: TIGER JPG .d.0.M.M..N.YM?.....TIGER PNG .d.0.M.M....YM`.X... 00200: P2D2A BMP .dZs.M.M..Cs.MQ?z...LMMS BMP .d.0.M.M..7.WM[.8... 00240: TIGER BMP ..[s.M.M...r.M.?z...MARIO BMP .d.r.M.M...r.M.?*... 00280: MARIO PNG .d.0.M.M...tSM2..A..BIRD BMP .d.r.M.M...r.Mm>z... 002C0: ASM51C FTH .d.1.M.M...k~M...7..C2PROG FTH ...1.M.M...6}M..d,.. 00300: TAQOZ FTH ..31.M.M...-.M..SV..3X5 TXT ..I1.M.M...xwK...... 00340: ASCIIARTTXT ..I1.M.M...xwK..l...CALCDEMOFTH ..I1.M.M...3KK..8... 00380: EASYFILEFTH ..I1.M.M...nXK..]...EASYNET FTH ..I1.M.M..6.XK...... 003C0: EXTEND FTH ..I1.M.M...aXK......FISH2 VT ..I1.M.M...ywK...;.. ok
Windows also ""helpfully"" puts the stupid 'System Volume Information' long-file-named directory on every drive you plug into it. So from inside TAQOZ, this is what I end up with:
TAQOZ# MOUNT .JTNCard 7E15_1584 PROP 32k 7,579M ok TAQOZ# DIR .JTNCard 7E15_1584 PROP 32k 7,579M PROP $0000_3F80 1980.00.00.00.00 0 B I n f. o $1D00_3F80 1980.03.15.00.03 110 S y s t. e $1BC0_3F80 1980.03.21.00.03 6,619,245 SYSTEM~1 $0000_4040 2018.12.25.16.53 0 _BOOT_P2.BIX $0000_40C0 2018.12.25.16.44 32 ok
'' +--------------------------------------------------------------------------+ '' LMM DEBUGGER - lmm_f CALL Modes...(not all modes supported in ROM) '' +--------------------------------------------------------------------------+ _MODE = $F << 5 ' mode bits defining the call b8..b5 (b4..b0 are modifier options) _SHIFT = 5 ' shr # to extract mode bits _HEX_ = 2 << 5 ' hex... _REV_ = 1 << 4 ' - reverse byte order _SP = 1 << 3 ' - space between hex output pairs '_DIGITS = 7..0 where 8->0 ' - no. of digits to display _LIST = 3 << 5 ' LIST memory line (1/4 longs) from cog/hub _ADDR2 = 1 << 4 ' 1= use lmm_p2 as to-address _LONG_ = 1 << 1 ' 1=display longs xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx _TXSTRING = 4 << 5 ' tx string (nul terminated) from hub _RXSTRING = 5 << 5 ' rx string _ECHO_ = 1 << 4 ' - echo char _PROMPT = 1 << 3 ' - prompt (lmm_x) _ADDR = 1 << 2 ' - addr of string buffer supplied _NOLF = 1 << 1 ' - strip <lf> _MONITOR = 7 << 5 ' goto rom monitor '' +--------------------------------------------------------------------------+ _SerialInit = $fcab8 ' Serial Initialise (lmm_x & lmm_bufad must be set first) _HubTxCR = $fcae4 ' Sends <cr><lf> (overwrites lmm_x) _HubTxRev = $fcaec ' Sends lmm_x with bytes reversed _HubTx = $fcaf0 ' Sends lmm_x (can be up to 4 bytes) _HubHexRev = $fcb24 ' Sends lmm_x with bytes reversed as Hex char(s) as defined in lmm_f _HubHex8 = $fcb28 ' Sends lmm_x as Hex char(s) after setting lmm_f as 8 hex chars _HubHex = $fcb2c ' Sends lmm_x as Hex char(s) as defined in lmm_f _HubTxStrVer = $fcb9c ' Sends $0 terminated string at lmm_p address after setting lmm_p=##_str_vers _HubTxString = $fcba4 ' Sends $0 terminated string at lmm_p address _HubListA2H = $fcbc4 ' List/Dump line(s) from lmm_p address to lmm_p2 address after setting lmm_f=#_LIST+_ADDR2 _HubList = $fcbc8 ' List/Dump line(s) from lmm_p address to lmm_p2 address according to lmm_f _HubRx = $fcb10 ' Recv char into lmm_x _HubRxStrMon = $fccc4 ' Recv string into lmm_bufad address after setting prompt=lmm_x=#"*" & params=lmm_f=#_RXSTRING+_ECHO_+_PROMPT _HubRxString = $fcccc ' Recv string into lmm_p/lmm_bufad address according to params in lmm_f _HubMonitor = $fcd78 ' Calls the Monitor; uses lmm_bufad as the input buffer address _RdLongCogHub = $fcf34 ' read cog/lut/hub long from lmm_p address into lmm_x, then lmm_p++ _str_vers = $fd014 ' locn of hub string, $0 terminated '' +--------------------------------------------------------------------------+
I have included a screenshot of my first "Hello World program in TAQOZ Forth.
HydraHacker
Just remember that words that require parameters expect them on the stack before executing. So 32 EMIT will emit the value 32 from the stack. SPACE does the same thing but ." HELLO WORLD!" is the normal form for printing a literal string. Notice the space between ." And the first part of the string since ." is a word and all words need to be separated by whitespace. Notice too that you can just type this in without having to create a definition so try this (copy and paste).
10 FOR CRLF ." HELLO WORLD!" NEXT
I tried your code and it works great, I might get to like Forth yet!
I just made changes to my code and reposted, I put the parameter before the word and it works better...thanks Peter.
HydraHacker