Interesting result using spin2cpp on code with fullduplexserial in it...
Rayman
Posts: 14,826
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?
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
http://forums.parallax.com/attachment.php?attachmentid=99241&d=1360890415
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?
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.
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.
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!
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