Richard,
looking at your code,i'm learning lots of things.
All the registers you have are constants. And that is what i've thought also in the beggining.
Code:
;----------------------- REGISTER -------------------------
REG_TEMP_INT con $1F
REG_TEMP_FRAC con $20
REG_TEMP_CONFIG con $21
REG_PART_REVISION con $FE
REG_MODE con $09
REG_SPO2_CONFIG con $0A ;SPO2_ADC_RGE[6:5]SPO2_SR[4:2]LED_PW[1:0]
REG_LED1_PA con $0C
REG_LED2_PA con $0D
FIFO_WR_PTR con $04 ;FIFO_WR_PTR[4:0]
FIFO_RD_PTR con $06
FIFO_DATA con $07
FIFO_CONFIG con $08 ;FIFO_A_FULL[3:0] SMP_AVE[7:5]
STATUS1 con 0 ;A_FULL[7]
' -----------------------------------------------------------------------------|
But in the manual it says that we never use constants for the I2C command.
What i have realised is that you refer to the
everytime you need to asign a constant value to it. Is that right? with that way we alter the restriction of using constants. (or am i wrong?)
Sencod question.
I see you are always using the Write Address:
Code:
ADDR = $ae ; addr is 0x57 << 1
reg = REG_PART_REVISION
i2cread SDA,scl,ADDR,reg,[REVISION,PARTID]
reg = REG_MODE
i2cwrite SDA,scl,ADDR,reg,[3]
reg = REG_SPO2_CONFIG
i2cwrite SDA,scl,ADDR,reg,[$20]
reg = REG_LED2_PA
i2cwrite SDA,scl,ADDR,reg,[9]
reg = REG_LED1_PA
i2cwrite SDA,scl,ADDR,reg,[9]
reg = FIFO_CONFIG
i2cwrite SDA,scl,ADDR,reg,[16]
even if you want to read from:
Code:
reg= REG_TEMP_INT
i2cread sda,scl,ADDR,reg,[fifo[0],fifo[1]]
im confused here. When do we use the write address and when do we use the read address!!!
Bookmarks