Selecting the appropriate device in code
NewBee
Posts: 35
Can someone please point me to a paper that tells me how to read this code?
Thanks,
Bob
#SELECT $STAMP
· #CASE BS2, BS2E, BS2PE
··· T1200······ CON···· 813
··· T2400······ CON···· 396
··· T4800······ CON···· 188
··· T9600······ CON···· 84
··· T19K2······ CON···· 32
··· TMidi······ CON···· 12
··· T38K4······ CON···· 6
· #CASE BS2SX, BS2P
··· T1200······ CON···· 2063
··· T2400······ CON···· 1021
··· T4800······ CON···· 500
··· T9600······ CON···· 240
··· T19K2······ CON···· 110
··· TMidi······ CON···· 60
··· T38K4······ CON···· 45
· #CASE BS2PX
··· T1200······ CON···· 3313
··· T2400······ CON···· 1646
··· T4800······ CON···· 813
··· T9600······ CON···· 396
··· T19K2······ CON···· 188
··· TMidi······ CON···· 108
··· T38K4······ CON···· 84
#ENDSELECT
Thanks,
Bob
#SELECT $STAMP
· #CASE BS2, BS2E, BS2PE
··· T1200······ CON···· 813
··· T2400······ CON···· 396
··· T4800······ CON···· 188
··· T9600······ CON···· 84
··· T19K2······ CON···· 32
··· TMidi······ CON···· 12
··· T38K4······ CON···· 6
· #CASE BS2SX, BS2P
··· T1200······ CON···· 2063
··· T2400······ CON···· 1021
··· T4800······ CON···· 500
··· T9600······ CON···· 240
··· T19K2······ CON···· 110
··· TMidi······ CON···· 60
··· T38K4······ CON···· 45
· #CASE BS2PX
··· T1200······ CON···· 3313
··· T2400······ CON···· 1646
··· T4800······ CON···· 813
··· T9600······ CON···· 396
··· T19K2······ CON···· 188
··· TMidi······ CON···· 108
··· T38K4······ CON···· 84
#ENDSELECT
Comments
The purpose of this particular code is to allow PBASIC code that contains serial I/O to run with any of the Basic Stamp modules. If you look at (for example) the SERIN and SEROUT help pages in the PBASIC help system, you'll see that the code number for a particular serial baud rate depends on the kind of Stamp you're using. If you use the wrong code for your Stamp, you simply won't be able to communicate through the serial commands. These conditional directives tell the PBASIC code which baud code to use once it knows which Stamp module you're using.
Post Edited (sylvie369) : 6/18/2010 4:10:05 PM GMT
When you say it "does not seem to properly initialize", what do you mean? What is it doing/not doing?
You do have a #STAMP directive for the 2p at the top of your code, right? You should have two lines that look like this:
...which you get by clicking the little yellow Stamp icon and the "2.5" icon up at the top of the PBASIC environment.
Suggestion: if you know you are only going to use your code with the 2p40, you could get rid of most of that, and just leave this part:
(that's the constants as defined in the 2p section of the conditionals).
In fact, if you knew in advance which baud rate you're using, you could simply use that one constant, and ignore all of the other code. You could reduce all of that to one line of constant declaration.
Again, thanks for your·help.
·