I have been working an a nice project for quite some time now. Everything is working nice but I have been waking against the memory limited space of the sx28. So I 'm now trying to optimise my code so that it fits all into the sx28.

I was wondering if somebody knows a simple way to set outputs on different pins high or low with one word.

ex.

I want to set ra.0 and rb.0 to high and ra.1 to low sometimes during my program flow. In some other time i need to set ra.0 low and rb.0 to high. Leaving the other pins unchanged.

Is thier a way to define that in a constant with a good name and use only the name afterwoods in the program flow? Is that gaining me program space then?

I 'm using sx/B.

Thanks for any suggestions.

stef---------- End of Message ----------

You can view the post on-line at:http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=280604Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.comThe Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

You can define a pin (for example ra.0)pinA0 var ra.0To make the pin high use pinA0 = 1 (this translates into setb ra.0)To make the pin low use pinA0 = 0 (this translates into clrb ra.0)Without seeing your code we cannot give good adviceon how to optimize your code.

regards peter---------- End of Message ----------

You can view the post on-line at:http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=280604#m280606Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.comThe Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

Hi PeterThanks for your reaktion. Sorry I can not post the code. The end user wants his code private so I have to respect that.

The post you made is verry clear. I alraedy use that like that. The only thing I was wondering. Can you do that also for several pins at the same time.

Something like pins VAR ra.0,rb.1,rb.6 pins = 1Your example is using a one to one relation. Can it be a one to many? (but not the complete poort and/or different ports)stef---------- End of Message ----------

You can view the post on-line at:http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=280604#m280608Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.comThe Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

You can define multiple constants like this:pinA0 CON $001 pinA1 CON $002pinA2 CON $004pinA3 CON $008 pinB0 CON $101pinB1 CON $102pinB2 CON $104pinB3 CON $108pinB4 CON $110pinB5 CON $120pinB6 CON $140pinB7 CON $180 pinC0 CON $201pinC1 CON $202pinC2 CON $204pinC3 CON $208pinC4 CON $210pinC5 CON $220pinC6 CON $240pinC7 CON $280You can combine pins of the same port like this:pinsB = pinB0 OR pinB3To set the pins specified by pinsBrb = rb OR pinsBTo clear the pins specified by pinsBpinsB = not pinsBrb = rb AND pinsBTo automatically set pins of the same port you can use a subroutineSUB setPortPins 'call this with a wordparameter like pinsBpinmask = __PARAM1port = __PARAM2branch port,setA,setB,setCreturnsetA:ra = ra OR pinmaskreturnsetB:rb = rb OR pinmaskreturnsetC:rc = rc OR pinmaskreturnENDSUBFor clear, you can define something simular using AND instead of OR.Question is if this really optimizes your code, because setting up pinsand calling the subroutine also takes quite some code.Another option to optimize is changing some of the sxb code into assembly.

regards peter---------- End of Message ----------

You can view the post on-line at:http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=280604#m280610Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.comThe Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

Thanks peterYou offen specify "same port ". So it is not possible to AND/OR on pins from different ports?

Stef---------- End of Message ----------

You can view the post on-line at:http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=280604#m280612Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.comThe Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

No, as there are no assembly statements that operate on multiple ports.

regards peter---------- End of Message ----------

You can view the post on-line at:http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=280604#m280613Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.comThe Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

You can view the post on-line at:http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=280604#m280617Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.comThe Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

Make sure you are using subroutines for tasks you perform more than once. SX/B commands like SERIN, SEROUT, PAUSE, etc. actually generate a lot of SX assembly commands each time they appear in a program. If you place these commands in their own subroutine they will appear only once in the program (and thus generate only one sequence of assembly commands) but can be called multiple times. The impact of this can be dramatic for some programs.

- Sparks---------- End of Message ----------

You can view the post on-line at:http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=280604#m280772Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.comThe Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

Hi sparksI will look into it. thanks for the tip. I also use a lot of DATA arguments to store some static data. They seem to took also a lot off place. Has someone experiance (perhaps a schema and some examples) to connect memory to the sx28. I can then leave my program in the sx28 and place the data in the memory ic. The only problem then is that I have not mutch i/O pins free.

stef---------- End of Message ----------

You can view the post on-line at:http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=280604#m280802Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.comThe Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)

There is an example program (and circuit) for implementing an I2C EEPROM in SX/B Help.

---------- End of Message ----------

You can view the post on-line at:http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=280604#m280835Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.comThe Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)