What is st_1_raw.0 ?
Where do you test rdy bit or read st_1 ...
Hi J,
Possibly a bit tangled, but generally something like this.
___________________________________________________________
'SELF TEST'+++++++++++++++++++++++++++++++++++++++++++
SPICSOn
compss = 0 'CHIP SELECT COMPASS ON
SPISend 0x0a 'CONFIG CNTL1
SPISend 0x00 'POWER DOWN
SPISend 0x0c 'ASTC
SPISend 0x40 'SELF BIT= 1
SPISend 0x0a 'CONFIG CNTL1
SPISend 0x08 'SELF TEST MODE
SPISend 0x89 'ST1 0x09
Gosub dredy
SPISend 0x0c 'ASTC
SPISend 0x00 'SELF BIT= 0
SPISend 0x0a 'CONFIG CNTL1
SPISend 0x00 'POWER DOWN
compss = 1 'CHIP SELECT COMPASS OFF
SPICSOff
st_1_raw = b(0) 'BIT 0 = DRDY
x_raw.LB = b(1) 'BYTE
x_raw.HB = b(2) 'BYTE
y_raw.LB = b(3)
y_raw.HB = b(4)
z_raw.LB = b(5)
z_raw.HB = b(6)
Hseropen 9600 'After initialisation'??????????????????????????????????
Hserout "Ready!", CrLf
Hserout "SELF TEST ", #x_raw.LB, " ", #x_raw.HB, " ", #y_raw.LB, " ", #y_raw.HB, " ", #z_raw.LB, " ", #z_raw.HB, CrLf
'END SELF TEST'++++++++++++++++++++++++++++++++++++++
======================================================================
dredy: 'Test DRDY REG
For i = 0 To 6
compss = 0 'CHIP SELECT COMPASS ON
addr = 0x82 + i 'STI HXL-HZH
SPISend addr
SPIReceive data
b(i) = data
compss = 1 'CHIP SELECT COMPASS OFF
If st_1_raw.0 = 0 Then Goto dredy '<<<<<<<<<<<<<<<<<<
Next i
Return
_____________________________________________________________