Shop OBEX P1 Docs P2 Docs Learn Events
Interesting result using spin2cpp on code with fullduplexserial in it... — Parallax Forums

Interesting result using spin2cpp on code with fullduplexserial in it...

RaymanRayman Posts: 14,826
edited 2013-03-19 10:40 in Propeller 1
Just tried using spin2cpp on this test program for RamPage2 memory module.
RP2_test6 - Archive [Date 2013.03.02 Time 05.45].zip

I had a dream that maybe it would just work, but I know that's asking a lot...

Anyway, I first tried LMM mode and got garbage on the terminal window.
When I reverted to the non-P2 version of propgcc I got more legible text, but still not right.

Went to CMM mode and serial terminal text looked almost right.
Turned off all optimization (-O0 None) and now the text looks right.

Is this kind of the expected behavior when trying to directly port fullduplexserial to propgcc?

Comments

  • jazzedjazzed Posts: 11,803
    edited 2013-03-19 07:15
    Does it work with this manually ported package?
    http://forums.parallax.com/attachment.php?attachmentid=99241&d=1360890415
  • RaymanRayman Posts: 14,826
    edited 2013-03-19 08:07
    Ok, I did notice that in this forum. Guess that is the recommended replacement?
    I'll keep that in mind.

    But, because I want this to work on DE0, I think I need to replace all the serial stuff with printf.
    That's probably a better approach anyway, right?
  • SRLMSRLM Posts: 5,045
    edited 2013-03-19 09:06
    You should try adding {++volatile} to the inter-cog variables. After that, I've been able to convert FSRW and FFDS1. For example:
    var
        long {++volatile} shared_pointer
    
    Rayman wrote: »
    But, because I want this to work on DE0, I think I need to replace all the serial stuff with printf.
    That's probably a better approach anyway, right?

    On the Propeller 1, I prefer to use a standalone serial driver for most things, although printf is handy for quick testing programs. I can't speak for the Propeller 2.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-19 09:33
    jazzed wrote: »
    Is this a new improved version of FDS for PropGCC? If so, could you check it into the main PropGCC repository so it can be used by all users of PropGCC, not just SimpleIDE users?

    Thanks!
    David
  • jazzedjazzed Posts: 11,803
    edited 2013-03-19 09:38
    David Betz wrote: »
    Is this a new improved version of FDS for PropGCC? If so, could you check it into the main PropGCC repository so it can be used by all users of PropGCC, not just SimpleIDE users?

    Thanks!
    David

    You make many assumptions :) That program is over 5 years old now.
    It was committed once, but got morphed into our current FDX handler with stdio support.
  • RaymanRayman Posts: 14,826
    edited 2013-03-19 09:43
    nice tip SRLM... That seems to have fixed it... It appears that another way, besides adding "{++volatile}" to the spin is to find them in the .h file and add "volatile" there...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-19 09:45
    jazzed wrote: »
    You make many assumptions :) That program is over 5 years old now.
    It was committed once, but got morphed into our current FDX handler with stdio support.
    Okay thanks for the history lesson! :-)
    I'm going to need to look at this soon to port it to P2 so I guess I should know this code better than I seem to. Sorry!
  • ersmithersmith Posts: 6,092
    edited 2013-03-19 10:40
    Rayman wrote: »
    Went to CMM mode and serial terminal text looked almost right.
    Turned off all optimization (-O0 None) and now the text looks right.

    Is this kind of the expected behavior when trying to directly port fullduplexserial to propgcc?

    FullDuplexSerial works fine with -O0 and -O1, but sometimes has problems with -O2 and -Os (depending on timing). In general you'll have better luck with spin2cpp with -O1 rather than -Os.

    Alternatively, as others have suggested here, you can annotate the Spin source code with {++volatile} declarations to let the compiler know that variables will be modified behind its back. Using {++volatile} is better than manually editing the .h file, because it allows you to make changes to the .spin and re-run without having to edit the .h file every time.

    Eric
Sign In or Register to comment.