BS2 to BS2sx Upgrade, Programnolonger works.
NWUpgrades
Posts: 292
I am running PBasic 2.4.2.I have a BS2 Stamp on a BOE board that the following code works fine on, but when I use my BS2sx chip, it does not work correctly. Is there something I need to do to make my programs run on the BS2sx? Thanks for the help.
' {$STAMP BS2sx}
' {$PBASIC 2.5}
DEBUG "PROGRAM RUNNING"
counter VAR Word
FREQOUT 4, 2000, 3000
FOR counter = 1 TO 300
· PULSOUT 13, 812
· PULSOUT 12, 651
· PAUSE 20
· NEXT
· END
' {$STAMP BS2sx}
' {$PBASIC 2.5}
DEBUG "PROGRAM RUNNING"
counter VAR Word
FREQOUT 4, 2000, 3000
FOR counter = 1 TO 300
· PULSOUT 13, 812
· PULSOUT 12, 651
· PAUSE 20
· NEXT
· END
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Your PULSOUT commands on the BS2:
· PULSOUT 13, 812
· PULSOUT 12, 651
produce a 1.624 mS and a 1.302 mS pulse respectively because the duration is in 2uS units. Because the BS2sx is 2.5 times faster, the duration unit is .8 uS.
To get the same pulse width when running your code on the BS2sx, you would have to change your code to:
· PULSOUT 13, 2030
· PULSOUT 12, 1628
See the "Fast Facts" box in the BASIC Stamp Editor help file for the PULSOUT, PULSIN, FREQOUT and other commands that are effected by the difference in processor speed.
There is also some good information·under "Conditional Compilation Directives" in the help file·and the use of the Multiply Middle, */ operator to make your code processor independant. Consider the following code:
Good luck,
Duffer
Thanks again·
For setting the baud rate, you can again use conditional compilation as in the code below:
Look at the tables in the help file for the SERIN and SEROUT commands for the actual values to use in the #CASE statement groups for the processor(s) you're using.
Then just use one of the constants in your command that uses a baud rate parameter, i.e.
SERIN 1, T9600, [noparse][[/noparse]sData]
Then you can change processors without having to change your code.
Duffer
·
Duffer