I am running code that I built from the GitHub repository and it was current as of at least a few days ago. I'm running on a Mac and I'm loading PASM2 code. I haven't tried any of the high-level languages yet.
Since I live and work in Hollywood, I had to do this:
' This program creates an 8-LED Larson scanner on the P2 Eval board
dat org
ls_fwd mov ledpin, #56 ' start with p56
mov cycles, #7 ' light 7 going up
.loop drvl ledpin ' led on
waitx ##20_000_000/8 ' wait 1/8 second
drvh ledpin ' led off
add ledpin, #1 ' next pin
djnz cycles, #.loop ' done?
ls_rev mov ledpin, #63 ' start with p63
mov cycles, #7 ' light 7 going down
.loop drvl ledpin
waitx ##20_000_000/8
drvh ledpin
sub ledpin, #1
djnz cycles, #.loop
jmp #ls_fwd
ledpin res 1
cycles res 1
I didn't try this until I realized it was probably a Knight Rider thing...
Works fine for me. I'm a bit surprised you don't need any hubset instructions...
Does P2 always boot into RC mode? Maybe it does...
All the other programs I see start out with a hubset #0... Maybe you don't need that...
I wonder if the difference is whether you're running PASM2 or Spin/BASIC/C? I think Eric mentioned a while ago that the startup code for the high-level languages sets the clock appropriately for the FPGA and not for the P2-ES chip. Are all of the people who are having trouble trying to use Spin, BASIC, or C?
@Rayman
Thanks
It worked. Here's what I did.
I put fastspin.exe, loadp2exe, and larson.spin2 in my root user directory and entered the following commands.
Since I got it to work, I tried to find out what was wrong with my initial attempts.
First I tried deleting the quotation marks around the file names. It still worked.
Then I replaced loadp2.exe with the version that was in the latest spin2gui. That did not work. It gave me the same problem as I had before (appeared to load correctly, but nothing ran.)
I replaced loadp2.exe with the version you linked to, and it worked.
Tried the fastspin from the latest spin2gui and it worked (it is actually the same version.
So the problem seems to be the loadp2.exe that comes with the latest version of spin2gui.
I tried replacing the loadp2.exe in the spin2gui bin folder, but that didn't work. So I compared the command string in the the command line (that did work) and the config for spin2gui that did not work and tried removing options.
The one that worked removed the -k option. The configure command that worked is:
cmd.exe /c start %D/bin/loadp2 -pCOM9 %B -t
So the version of loadp2.exe in the latest spin2gui does not work, while the one posted by @Rayman does work with the -k option removed from the command configs.
I also tried a basic program and a c program, but they did not run (they worked when compiled for P1 and run on P1.)
I changed loadp2 from a 1-stage loader to a 2-stage loader a while ago. I'll have to check GitHub to see when I did that. The main reasons I wanted to use a 2-stage loader was to load at an address other than zero, and to load at the maximum speed of 1 byte per character sent.
If you use the 1-stage version your program will have to do a hubset. If you use the 2-stage version the user program does not need to do a hubset. However, loadp2 must be told the hubset value to use with the -m option. The devault hubset value is 0xff, which is the value used to set the FPGA P2 to 80MHz. For the P2 Eval board a different hubset value is needed. I'll look at the code Cluso posted to determine what the -m value should be for various frequencies.
Does P2 always boot into RC mode? Maybe it does...
All the other programs I see start out with a hubset #0... Maybe you don't need that...
Yes, reset sets to RCFAST.
hubset #0 is optional, I think some use that if they want to SW vector to the start again, or just to be sure... (ie TAQOZ might have changed sysclk)
I see the problem with FastSpin BASIC now...
It adds a hubset #255 right at the start.
This must be bad with real P2, seems to go off the rails...
I compiled a basic program using spin2gui and opened the resulting p2asm file. As you noted there was a hubset #255 near the start.
I changed that to hubset #0 saved the file and changed the extension to spin2.
Then I clicked on "compile & run" in spin2gui (with the changes to the command configs I noted in my previous post), and the program ran on the P2ES.
I did the same thing with a c program, and it also worked.
I'm not sure if hubset #0 is the best setting or not.
...
Then I clicked on "compile & run" in spin2gui (with the changes to the command configs I noted in my previous post), and the program ran on the P2ES.
I did the same thing with a c program, and it also worked.
I'm not sure if hubset #0 is the best setting or not.
Depends on your desired MHz, #0 is safe, and selects RCFAST.
Docs have
HUBSET ##%0000_000E_DDDD_DDMM_MMMM_MMMM_PPPP_CCSS 'set clock mode
where
E - Enables PLL
DDDDDD for PFD = XI/D
MMMMMMMMMM for VCO/M = PFD
PPPP for SysCLK from VCO
CC Xtal pins mode
SS Osc Select : RCFAST : RCSLOW : XI : PLL
This is a C program that I wrote and the resulting pasm file that I modified and then changed
the file extension to spin2 - Then compiled & run using spin2gui.
// testpinsc.c
// set & reset pins use propeller.h method
// Turn on LEDs at pins P1,3,4 for a couple of seconds, then just Pin P2.
// Turn off after a few seconds
main()
{
int y;
DIRA = 0;
OUTA = 0;
DIRA = 0b11110;
OUTA = 0b11010;
for(int i=0;i<10000000;i++);
OUTA = 0b0100;
for(i=0;i<10000000;i++);
}
'testpinsc.spin2
CON ' added these constants for 180MHz setting
_SETFREQ = $010C4708 ' constants are from Dave Hein's post
_ENAFREQ = $010C470B
dat
org 0
entry
cmp ptra, #0 wz
if_ne jmp #spininit
mov ptra, ptr_stackspace_
hubset #0 ' changed to this to be able to load & run
' added these 3 lines to set 180MHz
hubset ##_SETFREQ ' setup oscillator
waitx ##20_000_000/100 ' ~10ms
hubset ##_ENAFREQ ' enable oscillator
calla #@_main
cogexit
cogid arg01
cogstop arg01
spininit
rdlong objptr, ptra
add ptra, #4
rdlong result1, ptra
add ptra, #4
calla result1
jmp #cogexit
objptr
long @objmem
ptr_stackspace_
long @stackspace
result1
long 0
COG_BSS_START
fit 496
orgh $400
long 80000000
long 100
hubentry
_main
mov dira, #0
mov outa, #0
mov dira, #30
mov outa, #26
mov _var01, #0
' DIRA = 0;
' OUTA = 0;
' DIRA = 0b11110;
' OUTA = 0b11010;
'
' for(int i=0;i<10000000;i++);
LR__0001
cmps _var01, ##10000000 wcz
if_b add _var01, #1
if_b jmp #@LR__0001
mov outa, #4
'
' OUTA = 0b0100;
' for(i=0;i<10000000;i++);
mov _var01, #0
LR__0002
cmps _var01, ##10000000 wcz
if_b add _var01, #1
if_b jmp #@LR__0002
_main_ret
reta
hubexit
jmp #cogexit
objmem
long 0[0]
stackspace
long 0[1]
org COG_BSS_START
_var01
res 1
arg01
res 1
fit 496
If you want to use the 20MHz crystal part on the P2-Eval board as the source signal , should the _XOSC constant be %10 instead of %01 to engage the XI/XO loading caps? If so, this would change the LS nibble to:
If you want to use the 20MHz crystal part on the P2-Eval board as the source signal , should the _XOSC constant be %10 instead of %01 to engage the XI/XO loading caps? If so, this would change the LS nibble to:
Yes, see my Xtal frequency tests here
The correct/ideal is %10, but it does seems to oscillate on both %01 and %11, with largest deviation on the 'no cap' setting.
8 bit one is fine, the 16b one is black, with a small white rectangle in centre, on Chrome....
It has reasonable size tho, & if I save to disk and open in Paint, it displays ok in Paint.
Some browser issue, or a not quite right bmp ?
The real fun was getting an image of a P2ES into a 16bpp format that was small enough to allow the program to load it :-)
Look close and you'll notice that the image starts to jitter (after a few minutes). Touching the P2 MCU with a "deftly" placed finger makes the jitter stop for a few seconds...
I'll check some of the suggested ideas on removing the jitter and see how that goes.
Comments
If you want to try it, it's here in first post:
https://forums.parallax.com/discussion/169259/spinedit-editor-for-spin-spin2-and-fastbasic
I'm told it can work on a mac with the right serial port incantation...
I didn't try this until I realized it was probably a Knight Rider thing...
Works fine for me. I'm a bit surprised you don't need any hubset instructions...
Does P2 always boot into RC mode? Maybe it does...
All the other programs I see start out with a hubset #0... Maybe you don't need that...
Thanks Cluso, this works for me.
It's actually kind of nice to have serial routines stashed away at top of ram...
Thanks
It worked. Here's what I did.
I put fastspin.exe, loadp2exe, and larson.spin2 in my root user directory and entered the following commands. Since I got it to work, I tried to find out what was wrong with my initial attempts.
First I tried deleting the quotation marks around the file names. It still worked.
Then I replaced loadp2.exe with the version that was in the latest spin2gui. That did not work. It gave me the same problem as I had before (appeared to load correctly, but nothing ran.)
I replaced loadp2.exe with the version you linked to, and it worked.
Tried the fastspin from the latest spin2gui and it worked (it is actually the same version.
So the problem seems to be the loadp2.exe that comes with the latest version of spin2gui.
I tried replacing the loadp2.exe in the spin2gui bin folder, but that didn't work. So I compared the command string in the the command line (that did work) and the config for spin2gui that did not work and tried removing options.
The one that worked removed the -k option. The configure command that worked is:
So the version of loadp2.exe in the latest spin2gui does not work, while the one posted by @Rayman does work with the -k option removed from the command configs.
I also tried a basic program and a c program, but they did not run (they worked when compiled for P1 and run on P1.)
Thanks for your help.
Tom
I just tried a .bas file in SpinEdit…
It doesn't work their either... Strange spin2 works and bas doesn't...
If you use the 1-stage version your program will have to do a hubset. If you use the 2-stage version the user program does not need to do a hubset. However, loadp2 must be told the hubset value to use with the -m option. The devault hubset value is 0xff, which is the value used to set the FPGA P2 to 80MHz. For the P2 Eval board a different hubset value is needed. I'll look at the code Cluso posted to determine what the -m value should be for various frequencies.
I think it can do Spin (really Spin1.5 or so), but I'm just doing PASM with it...
hubset #0 is optional, I think some use that if they want to SW vector to the start again, or just to be sure... (ie TAQOZ might have changed sysclk)
It adds a hubset #255 right at the start.
This must be bad with real P2, seems to go off the rails...
I compiled a basic program using spin2gui and opened the resulting p2asm file. As you noted there was a hubset #255 near the start.
I changed that to hubset #0 saved the file and changed the extension to spin2.
Then I clicked on "compile & run" in spin2gui (with the changes to the command configs I noted in my previous post), and the program ran on the P2ES.
I did the same thing with a c program, and it also worked.
I'm not sure if hubset #0 is the best setting or not.
Tom
That can work, but you probably want to take advantage of the ~200 MHz + you can get with crystal...
Depends on your desired MHz, #0 is safe, and selects RCFAST.
Docs have
HUBSET ##%0000_000E_DDDD_DDMM_MMMM_MMMM_PPPP_CCSS 'set clock mode
where
E - Enables PLL
DDDDDD for PFD = XI/D
MMMMMMMMMM for VCO/M = PFD
PPPP for SysCLK from VCO
CC Xtal pins mode
SS Osc Select : RCFAST : RCSLOW : XI : PLL
Yes, I think that was FPGA 80MHz, but in a real P2 it does SysCLK -> VCO, but also disables PLL, so yes, a bad combination....
the file extension to spin2 - Then compiled & run using spin2gui.
Yes, see my Xtal frequency tests here
The correct/ideal is %10, but it does seems to oscillate on both %01 and %11, with largest deviation on the 'no cap' setting.
Just change _XDIV, _XMUL & _XDIVP
Clock set to 250 MHz.
Looks very solid.
I think the changes originated from ozpropdev…
P4=vsync, P0=hsync, P1..P3 are RGB...
BMP seems black ?
8 bit one is fine, the 16b one is black, with a small white rectangle in centre, on Chrome....
It has reasonable size tho, & if I save to disk and open in Paint, it displays ok in Paint.
Some browser issue, or a not quite right bmp ?
Also like you it works fine when saved to disk. However it took many seconds to download and save to disk - perhaps its a timeout related issue.
Just change that line to: The real fun was getting an image of a P2ES into a 16bpp format that was small enough to allow the program to load it :-)
Look close and you'll notice that the image starts to jitter (after a few minutes). Touching the P2 MCU with a "deftly" placed finger makes the jitter stop for a few seconds...
I'll check some of the suggested ideas on removing the jitter and see how that goes.
config info:
Win 10 Parallels-VM, running on macOS 10.14.2
PNut v32i
dgately
With more chips in the wild, we are getting a better handle on the issues
I still cannot believe how well the P2 is performing, and what it can do! And we are only scratching the surface so far