Need help getting a SCP1000 Altimeter (from SparkFun) to interface with the Pro
I'm trying (so far unsuccessfully) to get my PropStick USB to communicate with an SCP1000 altimeter from SparkFun (www.sparkfun.com/commerce/product_info.php?products_id=8161). It uses SPI for communication.
I attached a screen capture of the SPI communication example for a simple command (get the revision id of the board). It's from page 24 of the specification document for the SCP1000 (also attached). The PST output is also attached.
Below is the code I tried using to get the RevId. Using SPI, transmit %00000000 and it should return 03hex, but it just returns %00000000
If some kind soul out there could help me find the err of my ways, I'd greatly appreciate it.
Thanks!
I attached a screen capture of the SPI communication example for a simple command (get the revision id of the board). It's from page 24 of the specification document for the SCP1000 (also attached). The PST output is also attached.
Below is the code I tried using to get the RevId. Using SPI, transmit %00000000 and it should return 03hex, but it just returns %00000000
If some kind soul out there could help me find the err of my ways, I'd greatly appreciate it.
Thanks!
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
#0,MSBPRE,LSBPRE,MSBPOST,LSBPOST 'Used for SHIFTIN routines
#4,LSBFIRST,MSBFIRST 'Used for SHIFTOUT routines
High = 1
Low = 0
Out = %1
'Pin on Prop Chip for LED Indicator
PIN_LED = 15
'//Pin assignments for VTI SCP1000-D01
SPI_CSB = 0 'Chip select out connected to SCP1000 CSB pin
SPI_SCK = 3 'Clock out to SCP1000 SCK pin
SPI_MISO = 1 'Data in connected to SCP1000 MISO pin
SPI_MOSI = 2 'Data out connected to SCP1000 MOSI pin
SPI_DRDY = 4 'Data ready connected to SCP1000 DRDY pin
VAR
long DataValue, objSPI
OBJ
Debug : "FullDuplexSerial"
PUB start | data,i
'start debugger
debug.start(31,30,0,19200)
'set pin direction for LED to output
dira[noparse][[/noparse]PIN_LED]~~
'flash the LED to confirm the program is running
repeat 10
!outa[noparse][[/noparse]PIN_LED]
waitcnt(clkfreq / 2 + cnt) '0.5 seconds
'blank the screen
debug.str(string(16))
'start H48C accelerometer
debug.Str(string("Starting SPI..."))
objSPI := false
objSPI := SPI.Start
'test startup of H48C
if (objSPI)
debug.Str(string("Started Successfully!",13))
else
debug.Str(string("Failed to Start!",13))
'display data from H48C & HM55B
if (objSPI)
data := %10101010
data := GetRev
debug.str(string("GetRev should equal 03h = "))
debug.bin(data,8)
debug.str(string(13))
debug.str(string("Done."))
else
debug.str(string("Error: SPI failed to start. Terminating...",13))
PRI GetRev : datar | i
'set MOSI, CSB, SCK out
dira [noparse][[/noparse] SPI_MOSI ] := Out
dira [noparse][[/noparse] SPI_CSB ] := Out
dira [noparse][[/noparse] SPI_SCK ] := Out
dira [noparse][[/noparse] SPI_MISO ] := %0
'set CLK, MOSI low
outa [noparse][[/noparse] SPI_SCK ] := Low
outa [noparse][[/noparse] SPI_MOSI ] := Low
'set CSB high, then low to reset it
outa [noparse][[/noparse] SPI_CSB ] := High
outa [noparse][[/noparse] SPI_CSB ] := Low
repeat 8
outa [noparse][[/noparse] SPI_SCK ] := High 'set CLK High
outa [noparse][[/noparse] SPI_MOSI ] := %0 'transmit bin '0' on MOSI
outa [noparse][[/noparse] SPI_SCK ] := Low 'set CLK low
repeat i from 7 to 0
outa [noparse][[/noparse] SPI_SCK ] := High 'set CLK High
'read MISO
if ina[noparse][[/noparse]SPI_MISO] == 1 'read MISO
datar |= |< i ' set bit i HIGH
else
datar &= !|< i ' set bit i LOW
outa [noparse][[/noparse] SPI_SCK ] := Low 'set CLK low
outa [noparse][[/noparse] SPI_CSB ] := High
return datar

Comments
Thank you for trying to help. I appreciate it very much.
However, I don't think your code works with the SCP1000 sensor. Your hex codes to pull the Temperature ($84) and Pressure ($7c and $80) are not found anywhere in the SCP1000 specification (attached).
With my circuit & sensor (which I have very little faith in to begin with), the outputs (without any division or manipulation) are: Pressure = 16777215, Temperature = 65535.
I tried changing the hex codes you had for Temp and Pres, but they resulted in the same outputs. Furthermore, I think 65535 is the max value for an integer, which makes the Temperature value look very suspicious.
During my Initialization function, I am pulling the REVID successfully. I am performing a ASIC Self Test, which is passing. The Operation Init function is working. The Status is returning as a success. I'm performing the 'low noise' calibration (which might or might not be needed). So, it looks like the sensor *should* be setup properly.
However, the raw temperature and pressure data is essentially blank/empty.
I have attached the SPIN code as an archive. A picture of the circuit and the specifications are attached to a previous post.
The output from PST is:
So what's the problem? Is my sensor toast? Is my circuit wrong? Is the way I'm pulling the Temperature and Pressure values wrong?
When I sent this, I was in US and did not have access to my lab to test. I have returned homw now and have just benched tested the unit and it still works as before. I did not use the resistors shown in the diagram as it is the only thing connected at this time. I had planned on using the same SPI as the SD card reader which was why the resistors are shown. My display is attached.
Donald