P2 Newbie Discussion
zappman
Posts: 418
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,
I've gathered together some tools for programming the P2 FPGA and bundled them with a very simple IDE as "spin2gui". You can find the most recent release at:
https://github.com/totalspectrum/spin2gui/releases
This should also work on the P2-ES, but obviously we haven't had a chance to test it yet. In the meantime, it does work on P1 as well, so you can test it out there (under Commands > Configure Commands... hit either "P2 defaults" or "P1 defaults" to switch between the two processors).
The compiler included with spin2gui is called "fastspin", although someday that name should change, because it now supports not only Spin but also BASIC (see docs/basic.md) and a little bit of C.
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. 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.
Thanks Peter for an easy to use environment.
Tom
Has 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: After I MOUNT the card I can open the root directory and DUMP it as if it were RAM.
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: 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.
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.
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:
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).
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