I typically get 65 degrees celsius for Dev_Temp but I think it should be closer to room temperature. I'm not sure if the board is defective or I'm reading the virtual registers properly
Does anyone know if I'm doing this correctly?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I do not know the board. But, I would be removing the WRITEs. This sets the registers to 128+6 then you read... My guess is that you not reading the temp but the value you just set. Or, ignore that and figure out what this write does....
I'm using this board https://www.sparkfun.com/products/15050 with GCB version 0.98.06 and an 18F4550.
This board has 3 physical registers:
Status
Write
Read
It uses virtual registers to access the remaining I2C registers.
This accessing of the virtual registers is described on
pages 24 to 26 of this document https://cdn.sparkfun.com/assets/c/2/9/0/a/AS7265x_Datasheet.pdf
and on
pages 11 to 14 of this document https://cdn.sparkfun.com/assets/8/5/f/0/3/AS7265x_Design_Considerations.pdf
This is all very confusing to me but here is what I wrote to read the device temperature:
'Address registers
#define Spectral_Sensor_WRITE_ADDR 146 ;0x92
#define Spectral_Sensor_READ_ADDR 147 ;0x93
#define Spectral_Sensor_VIRTUAL_WRITE_ADDR 128 ;0x80 = 1000 0000 MSb = 1
#define Spectral_Sensor_VIRTUAL_READ_ADDR 0
'Physical Registers
#define Status_Register 0
#define WRITE_Register 1
#define READ_Register 2
'Virtual Registers
#define Device_Temperature 6
'READ Temperature
TX_VALID_Status:
HI2CStart
HI2CSend Spectral_Sensor_WRITE_ADDR
HI2CSend Status_Register
HI2CRestart
HI2CSend Spectral_Sensor_READ_ADDR
HI2CReceive Status_Tx, NACK
HI2CStop
If Status_Tx.1 = 1 then Goto TX_VALID_Status ;Tx VALID bit
HI2CSTART
HI2CSend Spectral_Sensor_WRITE_ADDR
HI2CSend WRITE_Register
HI2CSend (Spectral_Sensor_VIRTUAL_WRITE_ADDR + Device_Temperature)
HI2CStop
RX_VALID_Temperature:
HI2CStart
HI2CSend Spectral_Sensor_WRITE_ADDR
HI2CSend Status_Register
HI2CRestart
HI2CSend Spectral_Sensor_READ_ADDR
HI2CReceive Status_Rx, NACK
HI2CStop
If Status_Rx.0 = 0 then Goto RX_VALID_Temperature
HSerPrint Dev_Temp
I typically get 65 degrees celsius for Dev_Temp but I think it should be closer to room temperature. I'm not sure if the board is defective or I'm reading the virtual registers properly
Does anyone know if I'm doing this correctly?
I do not know the board. But, I would be removing the WRITEs. This sets the registers to 128+6 then you read... My guess is that you not reading the temp but the value you just set. Or, ignore that and figure out what this write does....
HI2CSTART
HI2CSend Spectral_Sensor_WRITE_ADDR
HI2CSend WRITE_Register
HI2CSend (Spectral_Sensor_VIRTUAL_WRITE_ADDR + Device_Temperature)
HI2CStop