Code:
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
SCK = 5
MOSI = 4
MISO = 3
CSB = 6
DRDY = 2
High = 1
Low = 0
Out = %1
In = %0
VAR
OBJ
bs2 : "BS2_Functions"
tv : "tv_text"
PUB start
dira[CSB] := Out
dira[DRDY] := In
' outa[CSB] := High
bs2.start(20,21)
tv.start(12)
tv.out($00)
tv.str(string("Pressure Sensor Test",13,13))
outa[CSB] := Low
bs2.shiftout(MOSI,SCK,%00001010,BS2#MSBFIRST,8) ' ADDPTR Indirect Register Address
bs2.shiftout(MOSI,SCK,%00101101,BS2#MSBFIRST,8) ' 0x2D
outa[CSB] := High
outa[CSB] := Low
bs2.shiftout(MOSI,SCK,%00000110,BS2#MSBFIRST,8) ' DATAWR Indirect Register Data
bs2.shiftout(MOSI,SCK,%00000011,BS2#MSBFIRST,8) ' 0x03
outa[CSB] := High
outa[CSB] := Low
bs2.shiftout(MOSI,SCK,%00001110,BS2#MSBFIRST,8) ' OPERATION Operation Register
bs2.shiftout(MOSI,SCK,%00000010,BS2#MSBFIRST,8) ' 0x02
outa[CSB] := High
waitcnt(500_000+cnt)
outa[CSB] := Low
bs2.shiftout(MOSI,SCK,%00001110,BS2#MSBFIRST,8) ' Select High Resolution Mode
bs2.shiftout(MOSI,SCK,%00001010,BS2#MSBFIRST,8) ' 0x0A
outa[CSB] := High
repeat
repeat while ina[DRDY] == low
tv.out(00)
if ina[DRDY] == low
tv.str(string("LOW",13))
if ina[DRDY] == high
tv.str(string("HIGH",13))
outa[CSB] := Low
bs2.shiftout(MOSI,SCK,%01111100,BS2#MSBFIRST,8) ' 0x1F
bs2.shiftout(MOSI,SCK,%00000000,BS2#MSBFIRST,8) ' 0x00
tv.bin(bs2.shiftin(MISO,SCK,BS2#MSBFIRST,16),16) ' Read next 16bits
outa[CSB] := High
tv.str(string(13))
waitcnt(12_500_000+cnt)
Bookmarks