So-net無料ブログ作成
検索選択

BASIC Stamp の操作 [SX48]

BASIC Stamp を見ていたら 何か載っていた。
最初はオリジナルが要るらしい。


WS000298.JPG

' CLONE.BS2  rev 1.1
' (c) 1998 Tracy Allen, emesys
' allows one BS2 to program another
' by invoking the ALT-R algorithm.
' "MASTER" programs "TARGET" with
' an exact copy of its eeprom.
' Connections:
' --------- ---------
' | td|6----------->2|rd |
' | rd|7<-----------1|td |
' | rst|5----------->3|atn |
' | PRIME | | |
' | BS2 | | CLONE |
' |trigger|19--<0/1 | BS2 |19---------;
' | wow|20-->|-/\/-; | |20-->|-/\/-;
' --------- led 1k | --------- led 1k |
' | |
' ground ground
' The switch on pin 19 (in14) goes high to trigger
' programming of the CLONE. The "wow" led is an
' indicator to show progress, completion or failure.

rd con 2 ' handshake in from clone
td con 1 ' data out to clone
rst con 0 ' reset out to clone
wow con 15 ' led indicator

trigger var in14 ' in14=1 triggers cloning

cksm var word ' checksum
' also block address
' also handshake
bite var byte ' for data from eeprom
ix var byte ' index 128 blocks
jx var nib ' index 16 bytes/block

' Substitute your own program for "spain" below.
' All "spain" does is flash an led, and monitor an
' input to trigger the cloning routine.
'
spain:
freqout wow,1000,1
branch trigger,[spain,clone]
clone:
high td ' create break on rs232 line
pulsout rst,5 ' reset the clone-to-be
pause 100 ' hold the break condx
serout td,$4054,2,["BS2",0] ' send preamble
' "BS2null". sent here open loop;
' no error trapping.
pause 1 ' pacing.
for ix=0 to 127 ' send 128 blocks of 16 bytes
' total 2048 bytes
' can be modified to send only
' occupied blocks (per ALT-M).
cksm=ix+128 ' initialize checksum
' first block is adrs 128.
serout td,$4054,[cksm] ' send block adrs.
for jx=0 to 15 ' 16 bytes per block.
read ix*16+jx,bite ' get byte from adrs.
cksm=cksm+bite ' update checksum.
serout td,$4054,[bite] ' xmit byte to clone.
next ' next byte.
serout td,$4054,[-cksm//256] ' xmit checksum.
' now, target programs this eeprom block
' which usually takes 3-4 milliseconds.
' It returns a 0-1-0 pulse (ascii 0)
' when it is ready for next block.
pulsin rd,1,cksm ' wait for handshake
if cksm=0 then failed ' failed if no handshake..
toggle wow ' flip the indicator.
next ' next block.
serout td,$4054,[0] ' xmit null to clone.
pulsout rst,5 ' reset clone.
'
' now just pass time, wait for trigger to be rearmed.
' the "wow" led on the clone should now be pulsing too.
finish:
freqout wow,1000,2 ' pulses 2/sec for success.
branch trigger,[spain,finish]
failed: high wow ' stays high to signal failed.
branch trigger,[spain,failed]
end

 

The new command STORE in the BS2p and BS2pe make cloning a program from one Stamp to another much easier. A program running in bank 0, say, can copy itself to bank 7. Or, a program running in bank 0 can receive data from the serial port and WRITE that data directly into bank 7, and then run it as a program. (A checksum would probably be a good idea!)  This allows programming a Stamp over a modem or RF connection.

' {$STAMP BS2P}
' {$PBASIC 2.5}
' CloneP07.bsp for bank 0 or BS2p
' copies a program in bank 0 over to bank 7
' and then runs it from bank 7
'
x VAR byte
i VAR Word
READ 127,x ' retrieve current bank number
IF x & $f = 7 THEN
DEBUG CR,"Now running in bank 7",CR, bell
STOP
ELSE
FOR i=0 to 2047
STORE 0
READ i,x
STORE 7
WRITE i,x ' this is what takes time, ~ 5 milliseconds
DEBUG home,dec i ' show progress
NEXT
RUN 7
END

 


コメント(0) 

Javelin_Stamp_Module [SX48]

SX48の頂点的 
Javelin_Stamp と Basic_Stamp に適応する
回路図を書いてみました。
部品は手持ちの中から合いそうなものにしました。

RAMやEEPROM大きめにして、
ハイアドレスにもラッチを付けて、
大容量バージョンに・・
電源部はまだ書いていません。

Javelin_Stampは5V系ですが、
メモリー関係を3.3Vにするには
専用のバストランシーバが必要です。

FT232RLを使うとRS232Cシリアル入力が変わります。
SX48への書き込みは SX-Key (USB) なんかが必要です。

WS000300.JPG


コメント(0) 
メッセージを送る

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。

×

この広告は1年以上新しい記事の更新がないブログに表示されております。