Source Code
========
' {$STAMP BS2px}
' {$PBASIC 2.5}
StatusByte VAR Byte
Main:
GOSUB Init ' Initialization
GOSUB HW_RST ' Hardware Reset
END
Init:
DEBUG "-INIT-------------------------", CR
DEBUG "PIN# : 5432109876543210", CR
'Initialize the pins to high first since they are active high triggered
DIRH = %00000000 ' databus P8-P15 is input
OUTA = %1111 ' initialize control lines to high, P0=PS, P1=WR, P2=CS, P3=RD
DIRA = %1111 ' make them outputs
OUT4 = %1 ' set the RST pin high
DIR4 = %1 ' make RST pin as output pin
DEBUG "I/O : ", BIN16 INS, CR
DEBUG "-\INIT-------------------------", CR
Return
HWRST:
DO
OUT4 = %0 'RST Low
PAUSE 1 'min 8 clock cycles, assume 1ms is sufficient
OUT4 = %1 'RST High
GOSUB RDSTAT
LOOP UNTIL (StatusByte = $C4 OR StatusByte = $84)
RETURN
RDSTAT:
OUTA = %1010 'CS and PS Low
OUTA = %0010 'RD low
StatusByte = INH 'Read databus P8-P15
OUTA = %1010 'RD high
OUTA = %1111 'CS and PS High
DEBUG " Status: ", BIN8 StatusByte, " (", HEX2 StatusByte, ")", CR
RETURN
Ouput on Screen
=========================
-INIT-------------------------
PIN# : 5432109876543210
I/O : 0000000000011111
-\INIT-------------------------
Status: 00100001 (21)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
Status: 00100000 (20)
...
The data returned by LM629 seems to be fixed after reset is sent. As shown by the status, it is staying at hex20. Sometimes, it jump to maybe hex00 or hex30.
I did not attached a clock to the CLK input pin of LM629 in this example though. I was thinking that the RST is an asychronous input and so might not need a clock as long as I pause long enough, correct me if I am wrong in this line of thought.
If I were to connect a 8Mhz clock and power up, then the return status byte would be FF.