SmartPin Synchronous Serial Transmit
ke4pjw
Posts: 1,155
in Propeller 2
So I am looking at using a pair of Smartpins in Synchronous Serial Transmit mode. (%11100) and I need some help understanding how to initialize and use the Smartpins. The first hurtle I have to cross is how to setup the A - B pair. How do I determine what pin the clock is going to reside on?
I have looked at some other's code for configuring Smart Pins, but I don't have any examples of mode %11100. I just need another point of view. Feeling really stuck on something simple. I am missing some fundamental of the Smartpins.
Thanks in advance.
--Terry
I have looked at some other's code for configuring Smart Pins, but I don't have any examples of mode %11100. I just need another point of view. Feeling really stuck on something simple. I am missing some fundamental of the Smartpins.
Thanks in advance.
--Terry
Comments
The B-pin is configured to a neighbour pin, in this case 30.
Transmitting a byte ($71) results in.
In the smartpin docs the WRPIN mode setting config bits are listed as The BBBB portion is how you select which pin is the B input. Brian's examples above uses %0111<<24 (pin - 1) in the first example, and %1111<<24 (pin - 1, then inverted) in the second example.
You'll also note he's set bit six of the config. This is TT = %01, which forces the physical pin driver output on (Equivalent to DIRH in non-smartpin).
I will play around with it this evening.
There need to be examples in the manual, of various implementations, to help folks like myself better understand how to use these versatile features.
--Terry
Yeah, some terms aren't very distinctive. The one place that is strongly defined is "IN", "OUT" and "DIR" always represent what the cogs/streamers will see and/or control. The smartpins sit between IN/OUT/DIR and the real pins. When enabled, %MMMMM != 0, they change the meaning of IN/OUT/DIR.
Thanks for any help,
dgately
This bit is from the smart pins docs
Ah, the MSB... Read it several times, but didn't stick. Got it now!
Thank you
I do not understand.
Mike
That's what I've been working on here - https://forums.parallax.com/discussion/comment/1464427/#Comment_1464427
I've labelled it with ?? in the block diagram. Then spent a little time verifying more precisely its source, documenting in the subsequent post.
Interesting.
Enjoy!
Mike
I think I am going nuts! Or I have a poor fundamental understanding of sync-serial. Probably both!
MSB First commented out
MSB First Enabled
Your code looks and runs Ok here.
I did a slight change to the code to return the txout signal low on completion just to make better pictures.
Well, good to know I am not completely mad! LOL. Maybe this is a problem with fastspin or maybe how my Saleae analyzer is configured. I will press on.
Thank you for the additional code snippet. Quick question about it. What is "pa" used in rdpin?
BTW, saw your code for the pixel strip. The P2 is going to make one heck of a "pixel pusher". Can't wait to fill my yard with them come Christmas time!
Thanks,
Terry
Without Spin, my plans are kind of taken off the rails. At least I know I am not bonkers!
That means something else in the environment is causing your problem. I notice that you are not setting the clock frequency in your program. I guess you're assuming it is in RCFAST mode? I suspect loadp2 changes that. It'd be safest to explicitly set the clock mode and frequency to what you want them to be when your program starts up.
I will set the clock information and see if that makes a difference. I think it would be valuable to understand why this is happening. I will run it down as best I can.
Thanks,
Terry
It should work at any clock speed.
Strange...
I could have used the alias AKPIN #clkout or WRPIN #1,#clkout instead of RDPIN pa,#clkout.
The all achive the same outcome, clearing the smartpin status.
My thoughts exactly. I don't know if the problem is something with my machine or not. Do you have spin2gui installed? I am using version 1.3.7 It includes everything needed to compile and load the P2.
It would be interesting to see if it does the same for you.
Running code from spin2gui works Ok here.
I added a hubset #0 so waveform timing match pnut.
Not sure what's going on?
Let me add hubset #0 into the mix.
Setting the clock to 250Mhz makes no difference.
This must be something with my Windows machine. The only commonality is the binary touches the filesystem.
Oh well. I am at a loss. Thanks for looking at it. Apparently it is my Windows box. I will try another machine.
Programming with Pnut it works correctly sometimes.
Programming with spin2gui it never works correctly.
Booting from SD never works correctly.
I don't know what could be wrong, unless my P2 is flaky. Please watch the video. This is maddening.