My first Spin2 Program Fails
John Abshier
Posts: 1,116
in Propeller 2
I thought that this program would toggle pin 57 at approximately 5 Hz. But the toggle rate is .712Hz.
I am using SpinEdit 1.0 and fastspin 3.9.14 In SpinEdit I am using single stage loader with load crystal setting of $010c3f04. I stole the freq an osmode values from the test_CONTROL.spin2 program from Parallax.
John Abshier
CON freq = 160_000_000 osmode = $010c3f04 OBJ pins: "Pins.spin2" PUB Main pins.Low(56) ' Set LED 56 on (visual indicator that code is running) dirb[57] := 1 repeat waitcnt(cnt + 16_000_000) !outb[57]
I am using SpinEdit 1.0 and fastspin 3.9.14 In SpinEdit I am using single stage loader with load crystal setting of $010c3f04. I stole the freq an osmode values from the test_CONTROL.spin2 program from Parallax.
John Abshier
Comments
I think you may just need a: in your Main method before any other code. The constants freq, osmode you've set don't actually do anything on their own.
Cheers,
Jesse
Mike R.
Thanks for trying SpinEdit btw...
Kinda surprised dirb[57] and outb[57] work...
Maybe it's rigged so anything over 31 goes to the actual pin #...
Not sure I knew about pins.spin2 either. That looks interesting. Guess it comes with fastspin...
Pins.spin2 came with a set of programs for the accessory boards. I thought I got them from the Accessory Set product page https://parallax.com/product/64006-es But I don't see them there. Other programs included the control board, AV board and LED Matrix board. I guess Parallax withdrew them. outa is used for pin < 32 and outb with pin number for pins > 31.
John Abshier
John
I believe the examples are at this link.
https://forums.parallax.com/discussion/comment/1462664/#Comment_1462664
Tom
These are able to directly control one of the 64 pins.
I realize it isn't too hard to use inline asm for this, but it'd be nice to be part of the language.
Actually I am not so sure about this. Currently FastSpin uses some 'system' library for functions like this containing basically methods calling PASM with ASM...ENDASM.
This makes sense for some PASM instructions, but not for all of them. Having inline PASM is the shortest way using, intrinsics adds call and parameter overhead to it.
IMHO libraries like pins.spin2 make more sense, you as a programmer can, write, change and use them, and they are not hidden in the compiler, unable for you to change without your program not compiling with somebody elses fastspin.
So basically I like @ersmith's idea of the system object, being referenced for if some method is called without prefix of ser.xxx tv.xxx and xxx is nowhere else to be found.
But that system library has to be consistent between fastspin installations, so just eric can add and change there.
I think rather then hiding intrinsics in a invisible system library it would be better to include visible objects/classes in your source code.
That does not mean there should be no standard object providing intrinsics, but it should be used sparely.
anyways,
Mike
Well, fastspin will generally inline small functions, so there's little to no overhead for the intrinsics. But by the same token there's also little to no overhead for user libraries either, if the functions are not too complicated. I think you're right that having a set of standard objects that people can see and modify would be more useful to programmers than having intrinsics built in to the compiler.
Pins.spin2 seems like a reasonable start. It could easily use the DRVH, DRVL, etc. instructions, e.g.: and so on.
Not withdrawn, but moved to github: https://github.com/parallaxinc/propeller/tree/master/examples/Accessory Test Code