Any particular reason you're using Catalina rather than fastspin to compile these examples, @kg1? It'd be easier to just directly build everything in flexgui rather than having to convert with spin2cpp and then build in a different environment.
@ersmith Hi Eric I am a keen debugger. Perhaps some may say I should leave the "de" off debugger. Well I hope to get much code from SPIN and add it to C code I already have. I am also keen on multithreading and hope to put cogs to good use.
@RossH using Code:Blocks and selecting Tools->Download to Hub RAM and Debug with BlackCat
Result:
The Propeller is running!!! The debugger cannot control a running program.
Also on the command line:
You will need RossH to answer this.
He's been MIA for the past few weeks. It's a busy time for him as they cater for tourists, and also he's in the firezone south of Sydney. Hope all is well Ross!
Thank you for the info: @Cluso99 Your advice please: should I start a new discussion/ thread with heading: BlackCat
There must be some members who have used BlackCat and know the start-up procedure. Adding the -g3 parameter and compiling seems to cause the program not to run when using payload.
Kevin.
@Cluso99 I have found:
BlackBox Reference:
On Propeller 2 platforms, which generally use pins 62 & 63 for serial loading programs and for serial communications, Blackbox by default uses a second serial port provided by a PropPlug connected to pins 50 & 52.
I am not technical but I do have a Sparkfun FTDI cable which I hope I can substitute for a PropPlug.
On the Propeller 2 with regard to Pins 50 & 52 does it matter which one is TXD and/or RXD? I guess GND is also needed?
Many thanks,
Kevin.
Yes, you will need gnd. Presuming P63 & P62 are equivalent to P52 & P50, then P52 will be an input ie TXD on the serial plug.
The FTDI cable should be fine as you don’t need reset on this port.
If you have 1K to 5K resistors, connect in series with the FTDI cable TXD and RXD for safety until you are sure of the correct connection.
@RossH, @Cluso99 & @Tubular Thank you for your help. In the Device Manager I had two USB Serial Ports COM4 & COM6. I am still getting the original error dialogbox (see attachment). I guess I will need to wait for Ross.
Kevin
The assembly language syntax has changed between Propeller 1 and Propeller 2 (in P1 a colon is used at the beginning of temporary labels, in P2 it's a period instead). That change is only the tip of the iceberg though -- the two processors have different registers and instruction sets. spin2cpp only converts the Spin code, not the assembly code in the DAT section, so you'll have to convert the PASM code manually.
@ersmith Looking at output of spin2cpp from ILI9341-test.spin for Propeller 1:
__asm__( " .global __clkfreqval\n" );
__asm__( " __clkfreqval = 0x4c4b400\n" );
__asm__( " .global __clkmodeval\n" );
__asm__( " __clkmodeval = 0x6f\n" );
This is preventing the build for Propeller 1 and does not fit the Catalina documents I am reading for PASM within C.
Am I missing something?
Kevin.
@ersmith Looking at output of spin2cpp from ILI9341-test.spin for Propeller 1:
__asm__( " .global __clkfreqval\n" );
__asm__( " __clkfreqval = 0x4c4b400\n" );
__asm__( " .global __clkmodeval\n" );
__asm__( " __clkmodeval = 0x6f\n" );
This is preventing the build for Propeller 1 and does not fit the Catalina documents I am reading for PASM within C.
Am I missing something?
Kevin.
That syntax is used by PropGCC. I think that code is all wrapped in an #ifdef __propeller__. Does Catalina define the __propeller__ symbol? If it does then you'll have to manually edit it out. It sets the clock frequency and mode for PropGCC and is not applicable to Catalina (which probably has a different way to do that).
The above code is generated by spin2cpp for p1. No surrounding #ifdef __propeller__
I also searched all files in the Catalina folder for __propeller__ no result
I believe Catalina uses target files to set the clkfreq and clkmod values
I found __asm__ used in two .c files in the catalina folder so it must be defined somewhere.
I can't find clkfreqval or clkmodeval being used in code but _clkfreq is used.
I will quote out clkfreqval or clkmodeval lines for now.
Back to Propeller 2: In flexgui:
I will try to manually convert spin files meant for P1 to be used as spin files for use on P2:
Changing colon to period removes a lot of compile errors regarding temporary lables in asm.
del_millis mov time, CNT
add time, MSdelay
waitcnt time, #0
djnz delaycount, #del_millis
del_millis_ret ret
It seems that waitcnt is not available in PASM for P2? The error message is around the parameter time but is probably relates to number of parameters. Perhaps waitx could be used?
Many thanks,
Kevin.
@ersmith Wow! I never would have resolved that! Is spin2cpp meant to also cover PropGCC? SimpleIDE uses PropGCC?
Yes to both. In fact spin2cpp was originally intended for PropGCC, and the Catalina support is an afterthought.
The above code is generated by spin2cpp for p1. No surrounding #ifdef __propeller__
Ah, there's a bug there then. I misread some of the code, and I think it was intended to have an #ifdef around it.
It seems that waitcnt is not available in PASM for P2? The error message is around the parameter time but is probably relates to number of parameters. Perhaps waitx could be used?
Neither waitcnt nor CNT is available in P2 assembly. waitx can be used to achieve something similar, as can getct/waitct. The thread Cluso pointed to is definitely a useful one.
Conversion of PASM from P1 to P2
Please advise re the use of PAR in P1
Photo attached explains
Thanks Kevin
@ersmith Thanks Eric. I really want to compile the SPIN code for P2, say goodbye for now to PASM, then study plugins for Catalina and "slot in" the SPIN code into a plugin. I hope it works on a P2!
Cheers.
For passing a value in PAR for the P2 requires a SETQ before the COGINIT instruction to set the value into PTRA or PTRB (cannot recall which one but it's in the P2 docs).
@Cluso99 Thank you for your reply. "docs" do you mean "Parallax Propeller 2 Documentation v33 - Rev B Silicon" or are there others? I have attached page 16 of Parallax Propeller 2 Documentation v33 - Rev B Silicon. Are there any examples for PASM for P2 which would be a good starting point?
Also in the first file I have listed some reading material for PASM for P1 which I will work through.
I do not wish to become an expert in PASM. I hope to convert P1 code to P2 code and create a Catalina Plugin.
Regards,
Kevin.
Do you have the full FlexGUI release? The examples in the samples/ directory would be a place to look for some simple PASM code for P2 (e.g. the led_server_pasm.c program and the multiply.spin program). You could also use "spin2cpp --asm --p2 foo.c" to translate simple code snippets in C (or BASIC or Spin), and/or look at the listing file that "fastspin -l" produces (there's a FlexGUI menu option for that, under Files).
The Propeller2 is still in the Engineering Sample stage, so documentation is unfortunately sparse. Parallax has traditionally produced very good documentation for their products though, so we can expect that to improve as time goes on and the full release of the chip approaches.
For a more complicated example there's a VGA text driver at https://github.com/totalspectrum/p2_vga_text. The internals of it are written in P2 assembler but the wrapper is in Spin, which converts to C cleanly with spin2cpp (the C code compiles with fastspin, Catalina, and riscvp2). It might be an easier way to start plug-in development.
@ersmith Hi Eric Is there an include file missing? Or .spinh
C:\FlexGUI\samples>spin2cpp --ccode --main --files --p2 Smartpin.spin2
C:/FlexGUI/include/spin/SmartSerial.spin:22: error: dirl_ is not a function
C:/FlexGUI/include/spin/SmartSerial.spin:23: error: dirl_ is not a function
C:/FlexGUI/include/spin/SmartSerial.spin:30: error: wrpin_ is not a function
C:/FlexGUI/include/spin/SmartSerial.spin:31: error: wxpin_ is not a function
C:/FlexGUI/include/spin/SmartSerial.spin:32: error: dirh_ is not a function
C:/FlexGUI/include/spin/SmartSerial.spin:33: error: wrpin_ is not a function
C:/FlexGUI/include/spin/SmartSerial.spin:34: error: wxpin_ is not a function
C:/FlexGUI/include/spin/SmartSerial.spin:35: error: dirh_ is not a function
C:/FlexGUI/include/spin/SmartSerial.spin:43: error: dirl_ is not a function
C:/FlexGUI/include/spin/SmartSerial.spin:44: error: waitx_ is not a function
C:/FlexGUI/include/spin/SmartSerial.spin:81: error: waitx_ is not a function
C:/FlexGUI/include/spin/SmartSerial.spin:90: error: wypin_ is not a function
C:/FlexGUI/include/spin/SmartSerial.spin:91: error: waitx_ is not a function
The Spin2 language is still in flux, so not all of the builtin functions used in .spin2 files are supported by spin2cpp. This is unfortunate, but it's probably going to be a while before everything settles down.
Comments
Result:
The Propeller is running!!! The debugger cannot control a running program.
Also on the command line: Does BlackCat require a separate serial line?
Thanks,
Kevin.
He's been MIA for the past few weeks. It's a busy time for him as they cater for tourists, and also he's in the firezone south of Sydney. Hope all is well Ross!
There must be some members who have used BlackCat and know the start-up procedure. Adding the -g3 parameter and compiling seems to cause the program not to run when using payload.
Kevin.
BlackBox Reference:
On Propeller 2 platforms, which generally use pins 62 & 63 for serial loading programs and for serial communications, Blackbox by default uses a second serial port provided by a PropPlug connected to pins 50 & 52.
I am not technical but I do have a Sparkfun FTDI cable which I hope I can substitute for a PropPlug.
On the Propeller 2 with regard to Pins 50 & 52 does it matter which one is TXD and/or RXD? I guess GND is also needed?
Many thanks,
Kevin.
The FTDI cable should be fine as you don’t need reset on this port.
If you have 1K to 5K resistors, connect in series with the FTDI cable TXD and RXD for safety until you are sure of the correct connection.
As Cluso says you don't need to worry about reset, and the resistors are a good idea as long as comms aren't super fast
Kevin
Is this normal?
Thank you,
Kevin
__asm__( " .global __clkfreqval\n" );
__asm__( " __clkfreqval = 0x4c4b400\n" );
__asm__( " .global __clkmodeval\n" );
__asm__( " __clkmodeval = 0x6f\n" );
This is preventing the build for Propeller 1 and does not fit the Catalina documents I am reading for PASM within C.
Am I missing something?
Kevin.
That syntax is used by PropGCC. I think that code is all wrapped in an #ifdef __propeller__. Does Catalina define the __propeller__ symbol? If it does then you'll have to manually edit it out. It sets the clock frequency and mode for PropGCC and is not applicable to Catalina (which probably has a different way to do that).
I also searched all files in the Catalina folder for __propeller__ no result
I believe Catalina uses target files to set the clkfreq and clkmod values
I found __asm__ used in two .c files in the catalina folder so it must be defined somewhere.
I can't find clkfreqval or clkmodeval being used in code but _clkfreq is used.
I will quote out clkfreqval or clkmodeval lines for now.
Back to Propeller 2: In flexgui:
I will try to manually convert spin files meant for P1 to be used as spin files for use on P2:
Changing colon to period removes a lot of compile errors regarding temporary lables in asm. It seems that waitcnt is not available in PASM for P2? The error message is around the parameter time but is probably relates to number of parameters. Perhaps waitx could be used?
Many thanks,
Kevin.
Yes to both. In fact spin2cpp was originally intended for PropGCC, and the Catalina support is an afterthought.
Ah, there's a bug there then. I misread some of the code, and I think it was intended to have an #ifdef around it.
Neither waitcnt nor CNT is available in P2 assembly. waitx can be used to achieve something similar, as can getct/waitct. The thread Cluso pointed to is definitely a useful one.
Please advise re the use of PAR in P1
Photo attached explains
Thanks Kevin
@ersmith Thanks Eric. I really want to compile the SPIN code for P2, say goodbye for now to PASM, then study plugins for Catalina and "slot in" the SPIN code into a plugin. I hope it works on a P2!
Cheers.
Also in the first file I have listed some reading material for PASM for P1 which I will work through.
I do not wish to become an expert in PASM. I hope to convert P1 code to P2 code and create a Catalina Plugin.
Regards,
Kevin.
The Propeller2 is still in the Engineering Sample stage, so documentation is unfortunately sparse. Parallax has traditionally produced very good documentation for their products though, so we can expect that to improve as time goes on and the full release of the chip approaches.