|
Read the code...
There are parts of the code marked " (DO NOT CHANGE)" Don't change these parts of the code.
As to your questions, serin can be modified somewhat by the initializations you choose. You do this by choosing which variables the master CPU should send the STAMP2. Once you choose them (by putting 1's in the appropriate place to make the c_variablename constant equal to 1), they are fixed until you download a new program to the STAMP2.
After choosing the varialbes you want to get sent, you have to actually have your serin command match the variables requested. The most common cause of the "basic init error" LED going red is that the STAMP2 program asks for a different number of variables with the serin command than it requested via the c_variablename constants.
As to the serout command, things are much more stable. Generally speaking you have nothing to change. The only change that is allowed is that if you are dying to save a few milliseconds, you can truncate the output series. I don't recommend it because it usually means you are too close to the edge. If your code is that sensitive that this saves your program, you are probably going to go over the edge for some other reason very soon.
In the interest of full disclosure, I will show you how to truncate the serout command, even though I don't recommend it. Suppose you only needed to output p1_y, relayA, p2_y, and relayB. In this case your serout command could be shortened to:
Serout USERCPU, OUTBAUD, [255,255,p1_y,relayA,p2_y,relayB]
Finally, note that there is no changing the pins that the STAMP2 uses to communicate with the Master CPU -- for either the Serin command or the Serout command. This only makes sense since the pins are etched in copper and are difficult to move via software control ;-)
Joe J.
|