BTW: Maybe it is a good idea to keep variables separate...
After changing "x" to "x99" in my assembly code, I got an error here:
PUB CreateP1TvColors()|i,x,p,y,r,g,b 'create colors used by graphics demo, starting at index #128
repeat i from 0 to 14
x:=((i+4)&$F)*$10 + $C 'mid brightness colors that start and green and run through yellow, red, purple, blue and then back to green
repeat j from 0 to 256
The variable "j" was being used without being declared as a local variable.
So, I guess it was using the long declared in the assembly block.
Actually, once that assembly driver is started, maybe this is perfectly fine.
Perhaps I should have gone the other route and just not defined i,j,k,x,y etc as local and just left them in the assembly code
"addpins" is one of the new operators, and it's recognized by fastspin 4.1.3. "av_basepin_ addpins 4" is the same as "av_basepin_ | (4<<6)". This may be a case where having a lot of operators obscures what's going on.
I'm glad to see chip using 297 MHz clock in these demos.
That's what I'm using, but I spent an hour or so deliberating whether or not this is a good idea...
I might have to take a heat gun to it and see if this is going to work if the AC goes out during summer time...
Yeah! I got my 1551 ling long driver file to compile.
Now, I have to work on the top file...
Spin2 does not like how I include "smartserial" in my OBJ section:
OBJ
VGA : "1080p_TileDriver_3n.spin2" 'Note: You must set the fclk constant in this file to match _clkfreq
gr : "Graphics2b.spin2"
usb1: "OneCogKbM_rja2b" 'Note: You must change basepin and _FCLKFREQ settings in this file to match your setup
ser: "spin/SmartSerial"
It also doesn't like me putting the ".spin2" in the filenames...
Sorry, one more thing... Is there a list of the Spin2 operators somewhere?
You've probably found them by now, but I saw a .txt file attachment with the operators in Chip's 2020-2-9 15:28:40 post a couple pages back. And I think that file is in the latest zip file, too.
Minor note: FastSpin will let you redefine a constant later on but Spin will not...
I had two instances of this:
USB_V2MODE = %1_11011_0 + 1 << 16 ' In P2 silicon v2 all USB smart pin modes are consolidated to %11011.
This might be trouble:
' USB CRC constants:
USB5_POLY = %0_0101 >< 5 ' USB5 polynomial is reflected when calculating CRC
USB5_RESIDUAL = %0_1100 >< 5 ' Expected CRC5 residual value when checking received data
USB16_POLY = $8005 >< 16 ' USB16 polynomial is reflected when calculating CRC
USB16_RESIDUAL = $800d >< 16 ' Expected CRC16 residual value when checking received data
dirl_(USB_EVENT_REPO) ' DIR bit low puts smart pin in reset mode
wrpin_(SP_REPO1_MODE, USB_EVENT_REPO) ' Set "long repository" mode to act as an event mailbox
dirh_(USB_EVENT_REPO) ' Enable the event mailbox smart pin (will raise IN)
"pinfloat" will set the direction to low (like dirl_) and "pinlow" will set the direction to high (like dirh_). Use just plain "wrpin" instead of "wrpin_". fastspin 4.1.3 should accept all of those.
dirl_(USB_EVENT_REPO) ' DIR bit low puts smart pin in reset mode
wrpin_(SP_REPO1_MODE, USB_EVENT_REPO) ' Set "long repository" mode to act as an event mailbox
dirh_(USB_EVENT_REPO) ' Enable the event mailbox smart pin (will raise IN)
What to do here?
There are register variables, same as in PASM: DIRA/DIRB/OUTA/OUTB/INA/INB.
WRPIN/WXPIN/WYPIN/etc can be used in Spin2, as well as in PASM.
Okay. It's finding constant symbols that start with underscores, and for some reason I disallowed this in the object interface. I can't remember why. Let me change this...
Rayman, there are ways of achieving all these things in the PNut version of Spin2.
byte[base][index] 'look up a byte
To set up the clock, you only need to specify:
CON _clkfreq = 250_000_000 'assumes 20MHz crystal if no _xtlfreq specified
CON _xtlfreq = 16_000_000 'if your crystal frequency is not 20MHz, specify _xtlfreq
The compiler will pick the optimal PLL setting for you. You can see what it is in your code by using the constant clkmode_ and clkfreq_. Also Ctrl-L shows it.
And TEST is a PASM instruction, so it is a reserved word.
Until I get the documentation together for Spin2, there will be some ambiguities.
Comments
I thought that "=>" was going to change to ">=", like C++, but I think Fastspin didn't make this change, so I wonder about Spin2...
Also, I'm getting an error on this:
So, I think absolute value operator has changed...
I found the 2018 proposed operators here: https://forums.parallax.com/discussion/166416/spin2-operator-syntax/p17
Seems || is now ABS...
After changing "x" to "x99" in my assembly code, I got an error here:
The variable "j" was being used without being declared as a local variable.
So, I guess it was using the long declared in the assembly block.
Actually, once that assembly driver is started, maybe this is perfectly fine.
Perhaps I should have gone the other route and just not defined i,j,k,x,y etc as local and just left them in the assembly code
"addpins" is one of the new operators, and it's recognized by fastspin 4.1.3. "av_basepin_ addpins 4" is the same as "av_basepin_ | (4<<6)". This may be a case where having a lot of operators obscures what's going on.
That's what I'm using, but I spent an hour or so deliberating whether or not this is a good idea...
I might have to take a heat gun to it and see if this is going to work if the AC goes out during summer time...
I copied over a "DEC" routine from Spin1 that has this in it:
Gives me an error in Spin2....
Now, I have to work on the top file...
Spin2 does not like how I include "smartserial" in my OBJ section:
It also doesn't like me putting the ".spin2" in the filenames...
I get an error on this:
I see the example does this:
I guess the "16" means use the next free cog?
Does spin2 support preprocessor commands?
I'm getting an error in garryj's USB code on this line:
I had two instances of this:
This might be trouble:
Hope REV is same as ><
I guess you can't use . labels in hubexec?
Strange... I replace the DJNZ with sub wz and if_nz jmp and its ok with that. These are the same, right?
What to do here?
Spin2 doesn't seem to like this:
Doesn't like waitx() either: Think this might be waitct
ASM..ENDASM doesn't seem to work...
I thought it would compile now, but I get this (attached image).
No idea what to do about that...
In Spin2, there are three waits:
WAITCT(ct_target)
WAITUS(microseconds)
WAITMS(milliseconds)
There is also:
POLLCT(ct_target) 'returns true if past ct_target
There are register variables, same as in PASM: DIRA/DIRB/OUTA/OUTB/INA/INB.
WRPIN/WXPIN/WYPIN/etc can be used in Spin2, as well as in PASM.
Graphics2c_Spin2.spin2 compiles OK
The barebones file that calls it "GraphicsTest1a.spin2" gives this error message...
https://drive.google.com/file/d/1HWnhswX2fd3W9H1gYSFqNeWToBMO7N7T/view?usp=sharing
or this
Also, looks like to call a function that returns multiple results, you shouldn't put them in parenthesis like this does:
Didn't work though.
First problem seems to be with the clock setting...
Got VGA output after changing this part:
and also removing this:
byte[base][index] 'look up a byte
To set up the clock, you only need to specify:
CON _clkfreq = 250_000_000 'assumes 20MHz crystal if no _xtlfreq specified
CON _xtlfreq = 16_000_000 'if your crystal frequency is not 20MHz, specify _xtlfreq
The compiler will pick the optimal PLL setting for you. You can see what it is in your code by using the constant clkmode_ and clkfreq_. Also Ctrl-L shows it.
And TEST is a PASM instruction, so it is a reserved word.
Until I get the documentation together for Spin2, there will be some ambiguities.