This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OPT3101: measure phase always zero

Part Number: OPT3101

I try to get some measurement from the sensor.

I call calibrationSession_firstTimeBringUp() and I get these:

----------------------
Crosstalk Class Report
----------------------
I=0
Q=0
xtalkScale=0
illumXtalk=0
illumScale=0
illumDac=0
tmain=0
tillum=0
shiftIllumPhase=0
commonScale=0
Magnitude=
----------------------

----------------------
Crosstalk Class Report
----------------------
I=0
Q=0
xtalkScale=0
illumXtalk=1
illumScale=0
illumDac=25
tmain=0
tillum=1792
shiftIllumPhase=0
commonScale=0
Magnitude=
----------------------

----------------------
Crosstalk Class Report
----------------------
I=0
Q=0
xtalkScale=0
illumXtalk=1
illumScale=0
illumDac=31
tmain=0
tillum=1792
shiftIllumPhase=0
commonScale=0
Magnitude=
----------------------

Then I call a modified calibration function by fixing the temperature at 25, I got these. The phase number is always 0 whether I put something in front of the sensor or not.

----------------------------
Phase Temp Coff Class Report
----------------------------
coff=
coffReg=0
commonScale=0
----------------------------
-----------------------
Frame data Class Report
-----------------------
phase=0
phaseovl=0
phaseovlf2=0
ambovl=0
illumDac=0
ledChannel=0
frameStatus=0
dealiasFreq=0
frameCounter=0
amplitude=0
sigovl=0
dealiasBin=0
ambient=0
temp=0
tmain=0
tillum=1792
-----------------------

I notice that there is a function that trigger the phase offset measurement, but reference distance is always 0 when it is called in those calibration functions.

this->measurePhaseOffset(&this->calibration->phaseOffset[indx++], c0, c1 ? 'h' : 'l', refDistanceInCodes)

If I want to use it to measure distance, what reference distance I should put?

  • Hi,

    Have you set the COM port in the hostController? Can you do a quick test to make sure I2C to the device is working properly? You can run printf on one of the device registers accessed through dev.reg.REGISTER_NAME

    Best,

    Alex

  • Hi Alex,

    Forgot to mention, I have implemented the i2c read and write in the hostController.

    I tested the read and write and it is functioning properly. I have printed out all i2c read and write as follow, with register_value.

    I noticed that register "A" always read 0 and register "4" always read 170000

    TOF first time
    ->i2c read 89_e80300
    ->i2c write 89_e81b58
    ->i2c read 6e_e21a02
    ->i2c write 6e_ea1a02
    ->i2c read 7_0
    ->i2c write 7_800000
    ->i2c read d_6000
    ->i2c write d_806000
    ->i2c read 2_c8a492
    ->i2c write 2_e8a492
    ->i2c read 2_e8a492
    ->i2c write 2_28a492
    ->i2c read 1_400112
    ->i2c write 1_420112
    ->i2c read 1_420112
    ->i2c write 1_4a0112
    ->i2c read 3_80
    ->i2c read 1_5fffff
    ->i2c read 7_0
    ->i2c write 7_10000
    ->i2c read 2_c8a492
    ->i2c write 2_c8a4c8
    ->i2c read 2_c8a4c8
    ->i2c write 2_c8a448
    ->i2c read 50_120
    ->i2c write 50_121
    ->i2c read 50_121
    ->i2c read 50_121
    ->i2c read 2e_a00180
    ->i2c write 2e_a00780
    ->i2c read 72_c00000
    ->i2c write 72_c000c0
    ->i2c read 43_810000
    ->i2c write 43_810002
    ->i2c read 78_0
    ->i2c write 78_1000
    ->i2c read 78_1000
    ->i2c write 78_1080
    ->i2c read b_9c00f
    ->i2c write b_9c009
    ->i2c read 10_4000
    ->i2c write 10_c000
    ->i2c read f_4b4c14
    ->i2c read f_4b4c14
    ->i2c read f_4b4c14
    ->i2c write f_6b4c14
    ->i2c read f_6b4c14
    ->i2c write f_eb4c14
    ->i2c read f_eb4c14
    ->i2c write f_f14c14
    ->i2c read f_f14c14
    ->i2c write f_f15000
    ->i2c read 78_0
    ->i2c read 78_0
    ->i2c write 78_10000
    ->i2c read 9f_0
    ->i2c write 9f_1f
    ->i2c read 9f_1f
    ->i2c write 9f_1f01f
    ->i2c read 2e_a00180
    ->i2c write 2e_500180
    ->i2c read 85_200000
    ->i2c write 85_20267a
    ->i2c read 86_280000
    ->i2c write 86_282682
    ->i2c read 97_0
    ->i2c write 97_1f
    ->i2c read 97_1f
    ->i2c write 97_1f01f
    ->i2c read 14_0
    ->i2c write 14_20000
    ->i2c read 14_20000
    ->i2c write 14_30000
    ->i2c read 15_631010
    ->i2c write 15_631108
    ->i2c read 15_631108
    ->i2c write 15_b02108
    ->i2c read 16_140
    ->i2c write 16_100
    ->i2c read 16_100
    ->i2c write 16_c00100
    ->i2c read 13_0
    ->i2c write 13_32c80
    ->i2c read 14_0
    ->i2c write 14_10d8
    ->i2c read 13_0
    ->i2c read b9_ff0100
    ->i2c write b9_ff0500
    ->i2c read 2b_6000
    ->i2c write 2b_639c
    ->i2c read 2c_800
    ->i2c write 2c_12cc
    ->i2c read 2a_204978
    ->i2c write 2a_20c978
    ->i2c read 29_c30f3f
    ->i2c write 29_c30c5f
    ->i2c read 2b_6000
    ->i2c read 29_c30c5f
    ->i2c write 29_c30c41
    ->i2c read 2b_6000
    ->i2c write 2b_26000
    ->i2c read 29_c30c41
    ->i2c write 29_cf8c41
    ->i2c read 2c_800
    ->i2c read 29_cf8c41
    ->i2c write 29_cffc41
    ->i2c read 2c_800
    ->i2c write 2c_30800
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ->i2c read 2a_204978
    ->i2c read 8_0
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 80_1e4e00
    ->i2c read 2a_204978
    ->i2c read 8_0
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ->i2c read 2e_a00180
    ->i2c read 2e_a00180
    ->i2c write 2e_a00190
    ->i2c read 2e_a00180
    ->i2c read 2e_a00180
    ->i2c read 2e_a00180
    ->i2c read 3b_0
    ->i2c read 3c_0
    ->i2c read 2e_a00180
    ->i2c read 80_1e4e00
    ->i2c read 2a_204978
    ->i2c read 8_0
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ----------------------
    Crosstalk Class Report
    ----------------------
    I=0
    Q=0
    xtalkScale=0
    illumXtalk=0
    illumScale=0
    illumDac=0
    tmain=0
    tillum=0
    shiftIllumPhase=0
    commonScale=0
    Magnitude=
    ----------------------
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 71_0
    ->i2c read 80_1e4e00
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 2a_204978
    ->i2c write 2a_214978
    ->i2c read 2a_214978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 71_0
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ->i2c read 2e_a00180
    ->i2c read 2e_a00180
    ->i2c write 2e_a00080
    ->i2c read 2e_a00080
    ->i2c write 2e_a01080
    ->i2c read 2e_a00180
    ->i2c read 2e_a00180
    ->i2c read 2e_a00180
    ->i2c write 2e_a00380
    ->i2c read 3b_0
    ->i2c read 3c_0
    ->i2c read 2e_a00380
    ->i2c write 2e_a00180
    ->i2c read 2e_a00180
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 79_10000
    ->i2c read 29_c30f3f
    ->i2c read 2b_6000
    ->i2c read 80_1e5fff
    ->i2c write 80_1e5ffe
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 2a_204978
    ->i2c read 2a_20497b
    ->i2c write 2a_204979
    ->i2c read 2a_204979
    ->i2c read 2a_204979
    ->i2c write 2a_204978
    ->i2c read 71_0
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ----------------------
    Crosstalk Class Report
    ----------------------
    I=0
    Q=0
    xtalkScale=0
    illumXtalk=1
    illumScale=0
    illumDac=25
    tmain=0
    tillum=1792
    shiftIllumPhase=0
    commonScale=0
    Magnitude=
    ----------------------
    ¹->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 71_0
    ->i2c read 80_1e4e00
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 71_0
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ->i2c read 2e_a00180
    ->i2c read 2e_a00180
    ->i2c write 2e_a00080
    ->i2c read 2e_a00080
    ->i2c write 2e_a01080
    ->i2c read 2e_a00180
    ->i2c read 2e_a00180
    ->i2c read 2e_a00180
    ->i2c write 2e_a00380
    ->i2c read 3b_0
    ->i2c read 3c_0
    ->i2c read 2e_a00380
    ->i2c write 2e_a00180
    ->i2c read 2e_a00180
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 79_ffffff
    ->i2c read 29_c30f3f
    ->i2c read 2b_6000
    ->i2c read 80_1e4e00
    ->i2c read 14_3fff
    ->i2c read 14_0
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 71_0
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ----------------------
    Crosstalk Class Report
    ----------------------
    I=0
    Q=0
    xtalkScale=0
    illumXtalk=1
    illumScale=0
    illumDac=31
    tmain=0
    tillum=1792
    shiftIllumPhase=0
    commonScale=0
    Magnitude=
    ----------------------
    ¹Calibration now?
    ->i2c read 89_e80300
    ->i2c write 89_e81b58
    ->i2c read 6e_e21a02
    ->i2c write 6e_ea1a02
    ->i2c read 7_0
    ->i2c write 7_800000
    ->i2c read d_6000
    ->i2c write d_806000
    ->i2c read 2_c8a492
    ->i2c write 2_e8a492
    ->i2c read 2_e8a492
    ->i2c write 2_28a492
    ->i2c read 1_400112
    ->i2c write 1_420112
    ->i2c read 1_420112
    ->i2c write 1_4a0112
    ->i2c read 3_80
    ->i2c read 1_4a0112
    ->i2c write 1_5a0112
    ->i2c read 7_0
    ->i2c write 7_10000
    ->i2c read 2_c8a492
    ->i2c write 2_c8a4c8
    ->i2c read 2_c8a4c8
    ->i2c write 2_c8a448
    ->i2c read 50_120
    ->i2c write 50_121
    ->i2c read 50_121
    ->i2c read 50_121
    ->i2c read 2e_a00180
    ->i2c write 2e_a00780
    ->i2c read 72_c00000
    ->i2c write 72_c000c0
    ->i2c read 43_810000
    ->i2c write 43_810002
    ->i2c read 78_0
    ->i2c write 78_1000
    ->i2c read 78_1000
    ->i2c write 78_1080
    ->i2c read b_9c00f
    ->i2c write b_9c009
    ->i2c read 10_4000
    ->i2c write 10_c000
    ->i2c read f_4b4c14
    ->i2c read f_4b4c14
    ->i2c read f_4b4c14
    ->i2c write f_6b4c14
    ->i2c read f_6b4c14
    ->i2c write f_eb4c14
    ->i2c read f_eb4c14
    ->i2c write f_f14c14
    ->i2c read f_f14c14
    ->i2c write f_f15000
    ->i2c read 78_0
    ->i2c read 78_3fffff
    ->i2c read 9f_0
    ->i2c write 9f_1f
    ->i2c read 9f_1f
    ->i2c write 9f_1f01f
    ->i2c read 2e_a00180
    ->i2c write 2e_500180
    ->i2c read 85_200000
    ->i2c write 85_20267a
    ->i2c read 86_280000
    ->i2c write 86_282682
    ->i2c read 97_0
    ->i2c write 97_1f
    ->i2c read 97_1f
    ->i2c write 97_1f01f
    ->i2c read 14_0
    ->i2c write 14_20000
    ->i2c read 14_20000
    ->i2c write 14_30000
    ->i2c read 15_631010
    ->i2c write 15_631108
    ->i2c read 15_631108
    ->i2c write 15_b02108
    ->i2c read 16_140
    ->i2c write 16_100
    ->i2c read 16_100
    ->i2c write 16_c00100
    ->i2c read 13_0
    ->i2c write 13_32c80
    ->i2c read 14_0
    ->i2c write 14_10d8
    ->i2c read 13_32c80
    ->i2c read b9_ff03ff
    ->i2c write b9_ff07ff
    ->i2c read 2b_6000
    ->i2c write 2b_639c
    ->i2c read 2c_800
    ->i2c write 2c_12cc
    ->i2c read 2a_204978
    ->i2c write 2a_20c978
    ->i2c read 29_c30f3f
    ->i2c write 29_c30c5f
    ->i2c read 2b_6000
    ->i2c read 29_c30c5f
    ->i2c write 29_c30c41
    ->i2c read 2b_6000
    ->i2c write 2b_26000
    ->i2c read 29_c30c41
    ->i2c write 29_cf8c41
    ->i2c read 2c_800
    ->i2c read 29_cf8c41
    ->i2c write 29_cffc41
    ->i2c read 2c_800
    ->i2c write 2c_30800
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ->i2c read 2a_204978
    ->i2c read 8_0
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 80_1e4e00
    ->i2c read 2a_204978
    ->i2c read 8_0
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ->i2c read 2e_a00180
    ->i2c read 2e_a00180
    ->i2c write 2e_a00190
    ->i2c read 2e_a00180
    ->i2c read 2e_a00180
    ->i2c read 2e_a00180
    ->i2c read 3b_0
    ->i2c read 3c_0
    ->i2c read 2e_a00180
    ->i2c read 80_1e4e00
    ->i2c read 2a_204978
    ->i2c read 8_0
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ->i2c read 2e_a00180
    ->i2c read 71_0
    ->i2c read 2f_0
    ->i2c read 30_0
    ->i2c read 47_880
    ->i2c write 47_0
    ->i2c read 47_0
    ->i2c write 47_700000
    ->i2c read 2e_a00180
    ->i2c read 71_0
    ->i2c read 31_0
    ->i2c read 32_0
    ->i2c read 48_0
    ->i2c read 48_0
    ->i2c write 48_700000
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 43_810000
    ->i2c read 4a_0
    ->i2c read 43_810000
    ->i2c read c_0
    ->i2c read b4_0
    ->i2c read b4_0
    ->i2c read b4_0
    ->i2c read 71_0
    ->i2c read 80_1e4e00
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 43_810000
    ->i2c read 4a_0
    ->i2c read 43_810000
    ->i2c read c_0
    ->i2c read b4_0
    ->i2c read b4_0
    ->i2c read b4_0
    ->i2c read 71_0
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 10_4000
    ->i2c read 79_10000
    ->i2c read 29_c30f3f
    ->i2c read 2b_6000
    ->i2c read 80_1e4e7f
    ->i2c write 80_1e4e7e
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 2a_204978
    ->i2c read 2a_20497b
    ->i2c write 2a_204979
    ->i2c read 2a_204979
    ->i2c read 2a_204979
    ->i2c write 2a_204978
    ->i2c read 43_810000
    ->i2c read 4a_0
    ->i2c read 43_810000
    ->i2c read c_0
    ->i2c read b4_0
    ->i2c read b4_0
    ->i2c read b4_0
    ->i2c read 71_0
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ----------------------------
    Phase Temp Coff Class Report
    ----------------------------
    coff=
    coffReg=0
    commonScale=0
    ----------------------------
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 2a_204979
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 43_810000
    ->i2c read 4a_0
    ->i2c read 43_810000
    ->i2c read c_0
    ->i2c read b4_0
    ->i2c read b4_0
    ->i2c read b4_0
    ->i2c read 71_0
    ->i2c read 80_1e4e00
    ->i2c read 14_0
    ->i2c read 14_0
    ->i2c read 2a_204978
    ->i2c write 2a_214978
    ->i2c read 2a_214978
    ->i2c read 2a_214978
    ->i2c read 2a_214978
    ->i2c read 43_810000
    ->i2c read 4a_0
    ->i2c read 43_810000
    ->i2c read c_0
    ->i2c read b4_0
    ->i2c read b4_0
    ->i2c read b4_0
    ->i2c read 71_0
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 8_0
    ->i2c read 9_0
    ->i2c read a_0
    ->i2c read 4_170000
    ->i2c read 10_4000
    ->i2c read 79_10000
    ->i2c read 29_c30f3f
    ->i2c read 2b_6000
    ->i2c read 80_1e4e00
    ->i2c read 14_3ffff
    ->i2c write 14_2ffff
    ->i2c read 14_2ffff
    ->i2c write 14_ffff
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 2a_204978
    ->i2c read 43_810000
    ->i2c read 4a_0
    ->i2c read 43_810000
    ->i2c read c_0
    ->i2c read b4_0
    ->i2c read b4_0
    ->i2c read b4_0
    ->i2c read 71_0
    ->i2c read 80_1e4e00
    ->i2c write 80_1e4e01
    ----------------------------
    Phase Temp Coff Class Report
    ----------------------------
    coff=
    coffReg=0
    commonScale=0
    ----------------------------
    Frame Capture?
    -----------------------
    Frame data Class Report
    -----------------------
    phase=0
    phaseovl=0
    phaseovlf2=0
    ambovl=0
    illumDac=0
    ledChannel=0
    frameStatus=0
    dealiasFreq=0
    frameCounter=0
    amplitude=0
    sigovl=0
    dealiasBin=0
    ambient=0
    temp=0
    tmain=0
    tillum=1792
    -----------------------

  • Hi,

    Could you share the code you are using?

    Best,

    Alex

  • Hi Alex,

    This is the code I use for i2c read and write.

    void hostController::writeI2C(uint8_t address, uint32_t data) {
    
    	uint8_t trial = 0;
    	uint8_t writeData[] = {0,0,0,0};
    	uint32_t er = 0;
    
    	writeData[0] = address;
    	writeData[1] = data & 0xff;
    	writeData[2] = (data >> 8) & 0xff ;
    	writeData[3] = (data >> 16) & 0xff;
    
    	printf("->i2c trying to write %x_%x\n",address,data);
    
    	er = HAL_I2C_IsDeviceReady(&hi2c1, 0xB0, 1000, 1000);
    	if(er == HAL_OK)
    	{
    		while(trial < 99){
    			er = HAL_I2C_Master_Transmit(&hi2c1, 0xB0, (uint8_t *)&writeData, 4, 1000);
    			if(er == HAL_OK)
    			{
    				trial = 99; // printf("i2c sending ok!\n");
    			}else{
    				er = HAL_I2C_IsDeviceReady(&hi2c1, 0xB0, 100, 100);
    			}
    			trial++;
    		}
    		if (er != HAL_OK){
    			printf("i2c sending error ...\n");
    		}
    		HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
    	}else{
    		printf("i2c not ready ...\n");
    		HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);
    	}
    
    }
    
    uint32_t hostController::readI2C(uint8_t address) {
    //	uint32_t i2cReadValue=0;
    	uint8_t trial = 0;
    	uint32_t returnData = 0;
    	uint8_t  readData[] = {0,0,0};
    	uint32_t er = 0;
    
    	er = HAL_I2C_IsDeviceReady(&hi2c1, 0xB0, 1000, 1000);
    	if(er == HAL_OK)
    	{
    		while(trial < 99){
    			er = HAL_I2C_Master_Transmit(&hi2c1, 0xB0, (uint8_t *)&address, 1, 1000);
    			if(er == HAL_OK)
    			{
    				er = HAL_I2C_Master_Receive(&hi2c1, 0xB0, (uint8_t *)readData, 3, 1000);
    				if(er == HAL_OK)
    				{
    					trial = 99;
    					returnData = readData[0] + readData[1] * 256 + readData[2] * 256*256;
    					returnData = readData[0] + (readData[1] << 8) + (readData[2] << 16);
    				}else{
    					er = HAL_I2C_IsDeviceReady(&hi2c1, 0xB0, 100, 100);
    				}
    			}else{
    				er = HAL_I2C_IsDeviceReady(&hi2c1, 0xB0, 100, 100);
    			}
    			trial++;
    		}
    		if (er != HAL_OK){
    			returnData = 0; // 0xFFFFFF
    			printf("i2c reading error ...\n");
    		}
    		HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
    	}else{
    		printf("i2c ... ... ...\n");
    		HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);
    	}
    	printf("->i2c trying to read %x_%x\n", address, returnData);
    
    	return returnData;
    }

    And I use the original initialization code from the SDK.

    void OPT3101::device::initialize(){
    	// List of registers to initialize OPT3101 device after power-up
    
    	this->reg.tg_ovl_window_start = 7000; // //Overload flab observation window
    	this->reg.en_temp_conv = 1; // //Enables the internal
    
    	this->reg.config_tillum_msb = 8; // //Mode select between temp sensors
    	this->reg.en_tillum_12b = 1; // //Chooses between 12bit or 8 bit mode
    	this->reg.en_tillum_read = 1; // //Enable Ext temp sensor read
    	this->reg.temp_avg_illum = 0; // //Sets number of average for ext temp sensor measurement
    	this->reg.frame_vd_trig = 1; // //Trigger temp sensor measurement every VD
    	this->reg.i2c_en = 1;
    	this->reg.i2c_num_tran = 0; // //not required since default is correct
    	this->reg.i2c_rw = 1;
    	this->reg.i2c_num_bytes_tran1 = 1; ///<
    
    	this->reg.tsens_slave0 = 0x48; // //I2C Address for External Temp sensor for TX0 in super HDR Mode
    	this->reg.tsens_slave1 = 0x48; // //I2C Address for External Temp sensor for TX1 in super HDR Mode
    
    	this->reg.clip_mode_fc = 1; // //Enables Clip mode for Frequency correction
    	this->reg.clip_mode_temp = 0; // //Disables Clip mode for Temp coff phase correction
    	this->reg.clip_mode_offset = 0; // //Disables Clip mode for phase offset correction
    	this->reg.iq_read_data_sel = 3; // //Enables 16 bit frame counter
    	this->reg.iamb_max_sel = 12; // //Sets maximum ambient support
    	this->reg.en_temp_corr = 1; // //Enables Temperature Correction
    	this->reg.gpio1_obuf_en=1; // //Enabled output buffer on GPIO1 pin
    	this->reg.gpo1_mux_sel=2; 	    // //select dig_gpo_0 on gpio1
    	this->reg.dig_gpo_sel0 = 9; 	// //Select Data Ready on dig_gpo_0
    
    	this->reg.en_cont_fcalib=1; // //Enables continuous frequency calibration
    	this->reg.start_freq_calib=1; // //Starts the frequency calibration block
    	this->reg.en_floop=1; // //Enables the frequency correction loop
    	this->reg.en_auto_freq_count=1; // //Enables automatic frequency count
    	this->reg.en_freq_corr=1; // //Enables digital frequency correction
    	this->reg.sys_clk_divider = 8;  // //Divider for system clock
    	this->reg.ref_count_limit = 20480; // //Counter limit
    	this->reg.gpio2_obuf_en=0; // //Disables output buffer on GPIO2
    	this->reg.gpio2_ibuf_en=1; // //Enables ref clock input of GPIO2
    
    	this->reg.num_sub_frames = 31; // //Sub frames count
    	this->reg.num_avg_sub_frames = 31; // //Average frames count
    	this->reg.xtalk_filt_time_const = 5; // //Crosstalk filter time constant
    	this->reg.tg_seq_int_start 	= 9850; // //Sequence Start
    	this->reg.tg_seq_int_end 		= 9858; // //Sequence End
    	this->reg.tg_seq_int_mask_start 	= 31; // //Same as AvgFrame Count
    	this->reg.tg_seq_int_mask_end 	= 31; // //Same as AvgFrame Count
    
    	this->reg.en_processor_values = 1; // //Enables processor values
    	this->reg.en_sequencer = 1; // //Enables the Sequencer
    	this->reg.command0 = 0x108; // //Set Channel 1
    	this->reg.command1 = 0xB02; // //COMP1.
    	this->reg.command2 = 0x100; // //Set Channel 0
    	this->reg.command3 = 0xC00; // //COMP1_INV
    	this->reg.compare_reg1 = 26000; // //ThresholdH
    	this->reg.compare_reg2 = 4312; // //ThresholdH
    	this->reg.mux_sel_compin = 0; // //Selects Amplitude for Comparison
    	this->reg.en_tx1_on_tx0 = 1; // //Setting TX1 register and connect to TX0
    
    	this->reg.hdr_thr_high = 25500; // //High Threshold
    	this->reg.hdr_thr_low = 4812; // //Low Threshold
    	this->reg.en_adaptive_hdr = 1; // //Enables adaptive HDR feature
    
    	this->reg.illum_dac_h_tx0 = 2; // //High Current settings [011.2mA:5.6mA X 02]
    	this->reg.illum_scale_h_tx0 = 0; // //Illum scale for H [011.2mA:5.6mA X 02]
    
    	this->reg.illum_dac_l_tx0 = 1; // //High Current settings [002.8mA:2.8mA X 01]
    	this->reg.illum_scale_l_tx0 = 2; // //Illum scale for H [002.8mA:2.8mA X 01]
    
    	this->reg.illum_dac_h_tx1 = 31; // //High Current settings [173.6mA:5.6mA X 31]
    	this->reg.illum_scale_h_tx1 = 0; // //Illum scale for H [173.6mA:5.6mA X 31]
    
    	this->reg.illum_dac_l_tx1 = 31; // //High Current settings [043.4mA:1.4mA X 31]
    	this->reg.illum_scale_l_tx1 = 3; // //Illum scale for H [043.4mA:1.4mA X 31]
    
    	this->reg.tg_en = 1; // //Enables Timing Generator
    
    	this->configurationFlags_xtalkFilterTau =  5; // //This is not a register but a settings flag for the SDK
    	this->configurationFlags_monoshotMode =  false; // //This is not a register but a settings flag for the SDK
    	this->configurationFlags_xtalkSettlingOneTauInMilliSeconds      =  256; // //This is not a register but a settings flag for the SDK
    	this->configurationFlags_xtalkSettlingOneTauInDataReadyCounts   =  32; // //This is not a register but a settings flag for the SDK
    	this->configurationFlags_frameTimeInMilliSeconds                =  8; // //This is not a register but a settings flag for the SDK
    	this->configurationFlags_avgFrameCountExponentOfTwo             =  5; // //This is not a register but a settings flag for the SDK
    
    }

  • Hi,

    Are you able to share the full code? I am trying to see the functions you are calling in main.cpp and any modifications you have made to be able to review this and get the full picture.

    In i2c i see the print statement doesn't match the printout you shared earlier: "i2c trying to read %x_%x" vs "i2c read" in the printout.

    Best,

    Alex

  • Hi Alex,

    Attached is my project files in zip. 

    I modified a calibration function to call measurePhaseOffset, I expect to see some random numbers even without calibration.

    But I got all zeros from registers 8, 9, and A.


    TOF_i2c_.log
    TOF first time Hello!
    ->i2c trying to read 89_3e8
    ->i2c trying to write 89_1b58
    ->i2c trying to read 89_3e8
    ->i2c trying to read 6e_21ae2
    ->i2c trying to write 6e_a1ae2
    ->i2c trying to read 6e_a1ae2
    ->i2c trying to read 7_0
    ->i2c trying to write 7_800000
    ->i2c trying to read 7_800000
    ->i2c trying to read d_6000
    ->i2c trying to write d_806000
    ->i2c trying to read d_806000
    ->i2c trying to read 2_92a4c8
    ->i2c trying to write 2_b2a4c8
    ->i2c trying to read 2_b2a4c8
    ->i2c trying to read 2_b2a4c8
    ->i2c trying to write 2_32a4c8
    ->i2c trying to read 2_32a4c8
    ->i2c trying to read 1_120140
    ->i2c trying to read 1_ff0340
    ->i2c trying to read 3_800000
    ->i2c trying to read 1_120140
    ->i2c trying to read 7_0
    ->i2c trying to write 7_10000
    ->i2c trying to read 7_10000
    ->i2c trying to read 2_92a4c8
    ->i2c trying to read 2_92a4c8
    ->i2c trying to write 2_92a448
    ->i2c trying to read 2_92a448
    ->i2c trying to read 50_200100
    ->i2c trying to write 50_200101
    ->i2c trying to read 50_200101
    ->i2c trying to read 50_200101
    ->i2c trying to read 50_200100
    ->i2c trying to read 2e_8001a0
    ->i2c trying to write 2e_8007a0
    ->i2c trying to read 2e_8007a0
    ->i2c trying to read 72_c0
    ->i2c trying to read 43_81
    ->i2c trying to write 43_83
    ->i2c trying to read 43_83
    ->i2c trying to read 78_0
    ->i2c trying to write 78_1000
    ->i2c trying to read 78_1000
    ->i2c trying to read 78_1000
    ->i2c trying to write 78_1080
    ->i2c trying to read 78_1080
    ->i2c trying to read b_fc009
    ->i2c trying to read 10_ff4100
    ->i2c trying to write 10_ffc100
    ->i2c trying to read 10_ffc000
    ->i2c trying to read f_144c4b
    ->i2c trying to write f_154c4b
    ->i2c trying to read f_154c4b
    ->i2c trying to read f_154c4b
    ->i2c trying to write f_554c4b
    ->i2c trying to read f_554c4b
    ->i2c trying to read f_554c4b
    ->i2c trying to write f_754c4b
    ->i2c trying to read f_754c4b
    ->i2c trying to read f_754c4b
    ->i2c trying to write f_f54c4b
    ->i2c trying to read f_f54c4b
    ->i2c trying to read f_f54c4b
    ->i2c trying to write f_f14c4b
    ->i2c trying to read f_f14c4b
    ->i2c trying to read f_f14c4b
    ->i2c trying to write f_f15000
    ->i2c trying to read f_f15000
    ->i2c trying to read 78_0
    ->i2c trying to read 78_0
    ->i2c trying to write 78_10000
    ->i2c trying to read 78_10000
    ->i2c trying to read 9f_0
    ->i2c trying to write 9f_1f
    ->i2c trying to read 9f_1f
    ->i2c trying to read 9f_1f
    ->i2c trying to write 9f_1f01f
    ->i2c trying to read 9f_1f01f
    ->i2c trying to read 2e_8001a0
    ->i2c trying to write 2e_5001a0
    ->i2c trying to read 2e_5001a0
    ->i2c trying to read 85_20
    ->i2c trying to write 85_267a
    ->i2c trying to read 85_267a
    ->i2c trying to read 86_28
    ->i2c trying to write 86_2682
    ->i2c trying to read 86_2682
    ->i2c trying to read 97_0
    ->i2c trying to write 97_1f
    ->i2c trying to read 97_1f
    ->i2c trying to read 97_1f
    ->i2c trying to write 97_1f01f
    ->i2c trying to read 97_1f01f
    ->i2c trying to read 14_0
    ->i2c trying to write 14_20000
    ->i2c trying to read 14_20000
    ->i2c trying to read 14_20000
    ->i2c trying to write 14_30000
    ->i2c trying to read 14_30000
    ->i2c trying to read 15_101063
    ->i2c trying to write 15_101108
    ->i2c trying to read 15_101108
    ->i2c trying to read 15_101108
    ->i2c trying to write 15_b02108
    ->i2c trying to read 15_b02108
    ->i2c trying to read 16_400100
    ->i2c trying to read 16_400100
    ->i2c trying to write 16_c00100
    ->i2c trying to read 16_c00100
    ->i2c trying to read 13_0
    ->i2c trying to write 13_32c80
    ->i2c trying to read 13_32c80
    ->i2c trying to read 14_0
    ->i2c trying to write 14_10d8
    ->i2c trying to read 14_10d8
    ->i2c trying to read 13_0
    ->i2c trying to read b9_1ff
    ->i2c trying to write b9_5ff
    ->i2c trying to read b9_5ff
    ->i2c trying to read 2b_6000
    ->i2c trying to write 2b_639c
    ->i2c trying to read 2b_639c
    ->i2c trying to read 2c_800
    ->i2c trying to write 2c_12cc
    ->i2c trying to read 2c_12cc
    ->i2c trying to read 2a_784920
    ->i2c trying to write 2a_78c920
    ->i2c trying to read 2a_78c920
    ->i2c trying to read 29_3f0fc3
    ->i2c trying to write 29_3f0c43
    ->i2c trying to read 29_3f0c43
    ->i2c trying to read 2b_6000
    ->i2c trying to read 29_ff3f43
    ->i2c trying to write 29_ff3f41
    ->i2c trying to read 29_ff3f41
    ->i2c trying to read 2b_6000
    ->i2c trying to write 2b_26000
    ->i2c trying to read 2b_26000
    ->i2c trying to read 29_3f0fc3
    ->i2c trying to write 29_3f8fc3
    ->i2c trying to read 29_3f8fc3
    ->i2c trying to read 2c_800
    ->i2c trying to read 29_3f8fc3
    ->i2c trying to write 29_3fffc3
    ->i2c trying to read 29_3fffc3
    ->i2c trying to read 2c_800
    ->i2c trying to write 2c_30800
    ->i2c trying to read 2c_30800
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ->i2c trying to read 2a_784920
    ->i2c trying to read 8_ff3f55
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to read 2a_784920
    ->i2c trying to read 8_0
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_ff07a0
    ->i2c trying to write 2e_ff07b0
    ->i2c trying to read 2e_ff07b0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 3b_0
    ->i2c trying to read 3c_0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 80_4e1e
    ->i2c trying to read 2a_784920
    ->i2c trying to read 8_0
    ->i2c trying to write 8_20000
    ->i2c trying to read 8_0
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ----------------------
    Crosstalk Class Report
    ----------------------
    I=0
    Q=0
    xtalkScale=0
    illumXtalk=0
    illumScale=0
    illumDac=0
    tmain=0
    tillum=0
    shiftIllumPhase=0
    commonScale=0
    Magnitude=
    ----------------------
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 71_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 2a_784920
    ->i2c trying to write 2a_794920
    ->i2c trying to read 2a_794920
    ->i2c trying to read 2a_794920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 71_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to write 2e_8000a0
    ->i2c trying to read 2e_8000a0
    ->i2c trying to read 2e_8000a0
    ->i2c trying to write 2e_8010a0
    ->i2c trying to read 2e_8010a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to write 2e_8003a0
    ->i2c trying to read 2e_8003a0
    ->i2c trying to read 3b_0
    ->i2c trying to read 3c_0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 79_1
    ->i2c trying to read 29_3f0fc3
    ->i2c trying to read 2b_6000
    ->i2c trying to read 80_4e1e
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 71_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ----------------------
    Crosstalk Class Report
    ----------------------
    I=0
    Q=0
    xtalkScale=0
    illumXtalk=1
    illumScale=0
    illumDac=30
    tmain=0
    tillum=0
    shiftIllumPhase=0
    commonScale=0
    Magnitude=
    ----------------------
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 71_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 71_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to write 2e_8000a0
    ->i2c trying to read 2e_8000a0
    ->i2c trying to read 2e_8000a0
    ->i2c trying to write 2e_8010a0
    ->i2c trying to read 2e_8010a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to write 2e_8003a0
    ->i2c trying to read 2e_8003a0
    ->i2c trying to read 3b_0
    ->i2c trying to read 3c_0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 79_1
    ->i2c trying to read 29_3f0fc3
    ->i2c trying to read 2b_6000
    ->i2c trying to read 80_4e1e
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 71_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ----------------------
    Crosstalk Class Report
    ----------------------
    I=0
    Q=0
    xtalkScale=0
    illumXtalk=1
    illumScale=0
    illumDac=3
    tmain=0
    tillum=0
    shiftIllumPhase=0
    commonScale=0
    Magnitude=
    ----------------------
    Calibration or Measure now?
    ->i2c trying to read 89_3e8
    ->i2c trying to write 89_1b58
    ->i2c trying to read 89_1b58
    ->i2c trying to read 6e_21ae2
    ->i2c trying to write 6e_a1ae2
    ->i2c trying to read 6e_a1ae2
    ->i2c trying to read 7_0
    ->i2c trying to write 7_800000
    ->i2c trying to read 7_800000
    ->i2c trying to read d_6000
    ->i2c trying to write d_806000
    ->i2c trying to read d_806000
    ->i2c trying to read 2_92a4c8
    ->i2c trying to write 2_b2a4c8
    ->i2c trying to read 2_b2a4c8
    ->i2c trying to read 2_92a4c8
    ->i2c trying to write 2_12a4c8
    ->i2c trying to read 2_12a4c8
    ->i2c trying to read 1_120140
    ->i2c trying to read 1_120140
    ->i2c trying to write 1_1a0140
    ->i2c trying to read 1_1a0140
    ->i2c trying to read 3_800000
    ->i2c trying to read 1_ff0f40
    ->i2c trying to write 1_df0f40
    ->i2c trying to read 1_df0f40
    ->i2c trying to read 7_0
    ->i2c trying to write 7_10000
    ->i2c trying to read 7_10000
    ->i2c trying to read 2_92a4c8
    ->i2c trying to read 2_92a4c8
    ->i2c trying to write 2_92a448
    ->i2c trying to read 2_92a448
    ->i2c trying to read 50_200100
    ->i2c trying to write 50_200101
    ->i2c trying to read 50_200101
    ->i2c trying to read 50_200101
    ->i2c trying to read 50_200100
    ->i2c trying to read 2e_8001a0
    ->i2c trying to write 2e_8007a0
    ->i2c trying to read 2e_8007a0
    ->i2c trying to read 72_c0
    ->i2c trying to read 43_81
    ->i2c trying to write 43_83
    ->i2c trying to read 43_83
    ->i2c trying to read 78_0
    ->i2c trying to write 78_1000
    ->i2c trying to read 78_1000
    ->i2c trying to read 78_1000
    ->i2c trying to write 78_1080
    ->i2c trying to read 78_1080
    ->i2c trying to read b_fc009
    ->i2c trying to read 10_ff4300
    ->i2c trying to write 10_ffc300
    ->i2c trying to read 10_ffc000
    ->i2c trying to read f_144c4b
    ->i2c trying to write f_154c4b
    ->i2c trying to read f_154c4b
    ->i2c trying to read f_154c4b
    ->i2c trying to write f_554c4b
    ->i2c trying to read f_554c4b
    ->i2c trying to read f_554c4b
    ->i2c trying to write f_754c4b
    ->i2c trying to read f_754c4b
    ->i2c trying to read f_754c4b
    ->i2c trying to write f_f54c4b
    ->i2c trying to read f_f54c4b
    ->i2c trying to read f_f54c4b
    ->i2c trying to write f_f14c4b
    ->i2c trying to read f_f14c4b
    ->i2c trying to read f_f14c4b
    ->i2c trying to write f_f15000
    ->i2c trying to read f_f15000
    ->i2c trying to read 78_0
    ->i2c trying to read 78_0
    ->i2c trying to write 78_10000
    ->i2c trying to read 78_10000
    ->i2c trying to read 9f_0
    ->i2c trying to write 9f_1f
    ->i2c trying to read 9f_1f
    ->i2c trying to read 9f_1f
    ->i2c trying to write 9f_1f01f
    ->i2c trying to read 9f_1f01f
    ->i2c trying to read 2e_8001a0
    ->i2c trying to write 2e_5001a0
    ->i2c trying to read 2e_5001a0
    ->i2c trying to read 85_20
    ->i2c trying to write 85_267a
    ->i2c trying to read 85_267a
    ->i2c trying to read 86_28
    ->i2c trying to write 86_2682
    ->i2c trying to read 86_2682
    ->i2c trying to read 97_0
    ->i2c trying to write 97_1f
    ->i2c trying to read 97_1f
    ->i2c trying to read 97_1f
    ->i2c trying to write 97_1f01f
    ->i2c trying to read 97_1f01f
    ->i2c trying to read 14_0
    ->i2c trying to write 14_20000
    ->i2c trying to read 14_20000
    ->i2c trying to read 14_20000
    ->i2c trying to write 14_30000
    ->i2c trying to read 14_30000
    ->i2c trying to read 15_101063
    ->i2c trying to write 15_101108
    ->i2c trying to read 15_101108
    ->i2c trying to read 15_101108
    ->i2c trying to write 15_b02108
    ->i2c trying to read 15_b02108
    ->i2c trying to read 16_400100
    ->i2c trying to read 16_ffff3f
    ->i2c trying to write 16_c00f3f
    ->i2c trying to read 16_c00f3f
    ->i2c trying to read 13_0
    ->i2c trying to write 13_32c80
    ->i2c trying to read 13_32c80
    ->i2c trying to read 14_0
    ->i2c trying to write 14_10d8
    ->i2c trying to read 14_10d8
    ->i2c trying to read 13_0
    ->i2c trying to read b9_1ff
    ->i2c trying to write b9_5ff
    ->i2c trying to read b9_5ff
    ->i2c trying to read 2b_6000
    ->i2c trying to write 2b_639c
    ->i2c trying to read 2b_639c
    ->i2c trying to read 2c_800
    ->i2c trying to write 2c_12cc
    ->i2c trying to read 2c_12cc
    ->i2c trying to read 2a_784920
    ->i2c trying to write 2a_78c920
    ->i2c trying to read 2a_78c920
    ->i2c trying to read 29_3f0fc3
    ->i2c trying to write 29_3f0c43
    ->i2c trying to read 29_3f0c43
    ->i2c trying to read 2b_6000
    ->i2c trying to read 29_ff7f43
    ->i2c trying to write 29_ff7f41
    ->i2c trying to read 29_ff7f41
    ->i2c trying to read 2b_6000
    ->i2c trying to write 2b_26000
    ->i2c trying to read 2b_26000
    ->i2c trying to read 29_3f0fc3
    ->i2c trying to write 29_3f8fc3
    ->i2c trying to read 29_3f8fc3
    ->i2c trying to read 2c_800
    ->i2c trying to read 29_3f8fc3
    ->i2c trying to write 29_3fffc3
    ->i2c trying to read 29_3fffc3
    ->i2c trying to read 2c_800
    ->i2c trying to write 2c_30800
    ->i2c trying to read 2c_30800
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ->i2c trying to read 2a_784920
    ->i2c trying to read 8_ff3f48
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to read 2a_784920
    ->i2c trying to read 8_0
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_ffffa7
    ->i2c trying to write 2e_ffffb7
    ->i2c trying to read 2e_ffffb7
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 3b_0
    ->i2c trying to read 3c_0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 80_4e1e
    ->i2c trying to read 2a_784920
    ->i2c trying to read 8_0
    ->i2c trying to write 8_20000
    ->i2c trying to read 8_0
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 71_0
    ->i2c trying to read 2f_0
    ->i2c trying to read 30_0
    ->i2c trying to read 47_800800
    ->i2c trying to write 47_800000
    ->i2c trying to read 47_800000
    ->i2c trying to read 47_800000
    ->i2c trying to write 47_0
    ->i2c trying to read 47_0
    ->i2c trying to read 2e_8001a0
    ->i2c trying to read 71_0
    ->i2c trying to read 31_0
    ->i2c trying to read 32_0
    ->i2c trying to read 48_0
    ->i2c trying to read 48_0
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 43_81
    ->i2c trying to read 4a_0
    ->i2c trying to read 43_81
    ->i2c trying to read c_0
    ->i2c trying to read b4_0
    ->i2c trying to read b4_0
    ->i2c trying to read b4_0
    ->i2c trying to read 71_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 43_81
    ->i2c trying to write 43_80
    ->i2c trying to read 43_80
    ->i2c trying to read 4a_0
    ->i2c trying to read 43_80
    ->i2c trying to read c_0
    ->i2c trying to read b4_0
    ->i2c trying to read b4_0
    ->i2c trying to read b4_0
    ->i2c trying to read 71_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 10_4000
    ->i2c trying to read 79_1
    ->i2c trying to read 29_3f0fc3
    ->i2c trying to read 2b_6000
    ->i2c trying to read 80_4e1e
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 43_81
    ->i2c trying to read 4a_0
    ->i2c trying to read 43_81
    ->i2c trying to read c_0
    ->i2c trying to read b4_0
    ->i2c trying to read b4_0
    ->i2c trying to read b4_0
    ->i2c trying to read 71_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ----------------------------
    Phase Temp Coff Class Report
    ----------------------------
    coff=
    coffReg=0
    commonScale=0
    ----------------------------
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 43_81
    ->i2c trying to read 4a_0
    ->i2c trying to read 43_81
    ->i2c trying to read c_0
    ->i2c trying to read b4_0
    ->i2c trying to read b4_0
    ->i2c trying to read b4_0
    ->i2c trying to read 71_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 2a_784920
    ->i2c trying to write 2a_794920
    ->i2c trying to read 2a_794920
    ->i2c trying to read 2a_794920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 43_81
    ->i2c trying to write 43_80
    ->i2c trying to read 43_80
    ->i2c trying to read 4a_0
    ->i2c trying to read 43_80
    ->i2c trying to read c_0
    ->i2c trying to read b4_0
    ->i2c trying to read b4_0
    ->i2c trying to read b4_0
    ->i2c trying to read 71_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 8_0
    ->i2c trying to read 9_0
    ->i2c trying to read a_0
    ->i2c trying to read 4_17
    ->i2c trying to read 10_4000
    ->i2c trying to read 79_1
    ->i2c trying to read 29_3f0fc3
    ->i2c trying to read 2b_6000
    ->i2c trying to read 80_4e1e
    ->i2c trying to read 14_0
    ->i2c trying to read 14_0
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 2a_784920
    ->i2c trying to read 43_81
    ->i2c trying to read 4a_0
    ->i2c trying to read 43_81
    ->i2c trying to read c_0
    ->i2c trying to read b4_0
    ->i2c trying to read b4_0
    ->i2c trying to read b4_0
    ->i2c trying to read 71_0
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    ----------------------------
    Phase Temp Coff Class Report
    ----------------------------
    coff=
    coffReg=0
    commonScale=0
    ----------------------------
    

    Hello_TOF.zip

  • Hi,

    Thanks for providing this. I was not able to get to this this week, but will get back to you next week on this.

    Best,

    Alex

  • Hi Alex,

    While you are looking at my code,

    Can you let me know what the function measurePhaseOffset() or measureAndCorrectInternalCrosstalk() will return if I set those initialization registers according to the SDK?

    If I always get zeros is it normal? or I should at least get some random numbers?

    At least I can know whether the hardware or the code got problem.

    -----------------------
    Frame data Class Report
    -----------------------
    phase=0
    phaseovl=0
    phaseovlf2=0
    ambovl=0
    illumDac=0
    ledChannel=0
    frameStatus=0
    dealiasFreq=0
    frameCounter=0
    amplitude=0
    sigovl=0
    dealiasBin=0
    ambient=0
    temp=0
    tmain=0
    tillum=1792
    -----------------------

  • Hi,

    You should not get all zeros. Those methods have no return (void) but they modify the PhaseOffsetC class and CrosstalkC class respectively. Then the printout that you see is from running the report() function contained in those classes. The report function prints all the variables stored in the class.

    This is in simple terms the order you would want to run them: initialization then measureAndCorrectInternalCrosstalk() then report()

    If you are running report without running the measureAndCorrectInternalCrosstalk or measurePhaseOffset or another method like this then it could be that you would see zeros. Also the class you are printing should match the class passed to the measure method.

    Best,

    Alex

  • Hi Alex,

    Yes, I tried to call report within the OPT3101::device::measurePhaseOffset function and the phaseOffset is still zero.

    I checked the i2c read and write log and noticed that some registers will fall back to the default values after some time, 

    even though an immediate read after write has confirmed that the registers are successfully written, 

    for example, register 07, 02, 78, 2B, 2C, 80, etc have fallen back to the default values.

    I checked the power with oscilloscope and it's stable at 3.3V, and these read and write completed within one second. So I think there is no reset happening in between.

    What other reason could cause the registers to always go back to default values?

    ->i2c trying to read 0_0
    ->i2c trying to write 0_400000
    ->i2c trying to read 0_400000
    
    ->i2c trying to read 89_3e8
    ->i2c trying to write 89_1b58
    ->i2c trying to read 89_1b58
    
    ->i2c trying to read 6e_21ae2
    ->i2c trying to write 6e_a1ae2
    ->i2c trying to read 6e_a1ae2
    
    ->i2c trying to read 7_0
    ->i2c trying to write 7_800000
    ->i2c trying to read 7_800000
    
    ->i2c trying to read d_6000
    ->i2c trying to write d_806000
    ->i2c trying to read d_806000
    
    ->i2c trying to read 2_92a4c8
    ->i2c trying to write 2_b2a4c8
    ->i2c trying to read 2_b2a4c8
    
    ->i2c trying to read 2_b2a4c8
    ->i2c trying to write 2_32a4c8
    ->i2c trying to read 2_32a4c8
    
    ->i2c trying to read 1_120140
    
    ->i2c trying to read 1_120140
    ->i2c trying to write 1_1a0140
    ->i2c trying to read 1_1a0140
    
    ->i2c trying to read 3_800000
    
    ->i2c trying to read 1_1a0140
    
    ->i2c trying to read 7_0
    ->i2c trying to write 7_10000
    ->i2c trying to read 7_10000
    
    ->i2c trying to read 2_92a4c8
    
    ->i2c trying to read 2_92a4c8
    ->i2c trying to write 2_92a448
    ->i2c trying to read 2_92a448
    
    ->i2c trying to read 50_200100
    ->i2c trying to write 50_200101
    ->i2c trying to read 50_200101
    
    ->i2c trying to read 50_200101
    
    ->i2c trying to read 50_210101
    
    ->i2c trying to read 2e_8001a0
    ->i2c trying to write 2e_8007a0
    ->i2c trying to read 2e_8007a0
    
    ->i2c trying to read 72_c0
    
    ->i2c trying to read 43_81
    ->i2c trying to write 43_83
    ->i2c trying to read 43_83
    
    ->i2c trying to read 78_0
    ->i2c trying to write 78_1000
    ->i2c trying to read 78_1000
    
    ->i2c trying to read 78_1000
    ->i2c trying to write 78_1080
    ->i2c trying to read 78_1080
    
    ->i2c trying to read b_fc009
    
    ->i2c trying to read 10_4000
    ->i2c trying to write 10_c000
    ->i2c trying to read 10_c000
    
    ->i2c trying to read f_144c4b
    ->i2c trying to write f_154c4b
    ->i2c trying to read f_154c4b
    
    ->i2c trying to read f_154c4b
    ->i2c trying to write f_554c4b
    ->i2c trying to read f_554c4b
    
    ->i2c trying to read f_554c4b
    ->i2c trying to write f_754c4b
    ->i2c trying to read f_754c4b
    
    ->i2c trying to read f_754c4b
    ->i2c trying to write f_f54c4b
    ->i2c trying to read f_f54c4b
    
    ->i2c trying to read f_f54c4b
    ->i2c trying to write f_f14c4b
    ->i2c trying to read f_f14c4b
    
    ->i2c trying to read f_f14c4b
    ->i2c trying to write f_f15000
    ->i2c trying to read f_f15000
    
    ->i2c trying to read 78_0
    
    ->i2c trying to read 78_0
    ->i2c trying to write 78_10000
    ->i2c trying to read 78_10000
    
    ->i2c trying to read 9f_0
    ->i2c trying to write 9f_1f
    ->i2c trying to read 9f_1f
    
    ->i2c trying to read 9f_1f
    ->i2c trying to write 9f_1f01f
    ->i2c trying to read 9f_1f01f
    
    ->i2c trying to read 2e_8001a0
    ->i2c trying to write 2e_5001a0
    ->i2c trying to read 2e_5001a0
    
    ->i2c trying to read 85_20
    ->i2c trying to write 85_267a
    ->i2c trying to read 85_267a
    
    ->i2c trying to read 86_28
    ->i2c trying to write 86_2682
    ->i2c trying to read 86_2682
    
    ->i2c trying to read 97_0
    ->i2c trying to write 97_1f
    ->i2c trying to read 97_1f
    
    ->i2c trying to read 97_1f
    ->i2c trying to write 97_1f01f
    ->i2c trying to read 97_1f01f
    
    ->i2c trying to read 14_0
    ->i2c trying to write 14_20000
    ->i2c trying to read 14_20000
    
    ->i2c trying to read 14_20000
    ->i2c trying to write 14_30000
    ->i2c trying to read 14_30000
    
    ->i2c trying to read 15_101063
    ->i2c trying to write 15_101108
    ->i2c trying to read 15_101108
    
    ->i2c trying to read 15_101108
    ->i2c trying to write 15_b02108
    ->i2c trying to read 15_b02108
    
    ->i2c trying to read 16_400100
    
    ->i2c trying to read 16_400100
    ->i2c trying to write 16_c00100
    ->i2c trying to read 16_c00100
    
    ->i2c trying to read 13_0
    ->i2c trying to write 13_32c80
    ->i2c trying to read 13_32c80
    
    ->i2c trying to read 14_0
    ->i2c trying to write 14_10d8
    ->i2c trying to read 14_10d8
    
    ->i2c trying to read 13_0
    
    ->i2c trying to read b9_1ff
    ->i2c trying to write b9_5ff
    ->i2c trying to read b9_5ff
    
    ->i2c trying to read 2b_6000
    ->i2c trying to write 2b_639c
    ->i2c trying to read 2b_639c
    
    ->i2c trying to read 2c_800
    ->i2c trying to write 2c_12cc
    ->i2c trying to read 2c_12cc
    
    ->i2c trying to read 2a_784920
    ->i2c trying to write 2a_78c920
    ->i2c trying to read 2a_78c920
    
    ->i2c trying to read 29_3f0fc3
    ->i2c trying to write 29_3f0c43
    ->i2c trying to read 29_3f0c43
    
    ->i2c trying to read 2b_6000
    
    ->i2c trying to read 29_3f0c43
    ->i2c trying to write 29_3f0c41
    ->i2c trying to read 29_3f0c41
    
    ->i2c trying to read 2b_6000
    ->i2c trying to write 2b_26000
    ->i2c trying to read 2b_26000
    
    ->i2c trying to read 29_3f0fc3
    ->i2c trying to write 29_3f8fc3
    ->i2c trying to read 29_3f8fc3
    
    ->i2c trying to read 2c_800
    
    ->i2c trying to read 29_3f8fc3
    ->i2c trying to write 29_3fffc3
    ->i2c trying to read 29_3fffc3
    
    ->i2c trying to read 2c_800
    ->i2c trying to write 2c_30800
    ->i2c trying to read 2c_30800
    
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    
    ->i2c trying to read 2a_784920
    
    ->i2c trying to read 8_108fef
    
    ->i2c trying to read 14_0
    
    ->i2c trying to read 14_0
    
    ->i2c trying to read 80_4e1e
    
    ->i2c trying to read 2a_784920
    
    ->i2c trying to read 8_0
    
    ->i2c trying to read 14_0
    
    ->i2c trying to read 14_0
    
    ->i2c trying to read 80_4e1e
    ->i2c trying to write 80_4e1f
    ->i2c trying to read 80_4e1f
    

  • Thanks for this info. Were you able to check the I2C lines as well during these operations to make sure the reads are actually happening? It looks like I2C is working from this so in that case only reason to get default values is if the device was not configured before reading. Were you able to check on I2C lines with scope to confirm both that the device registers are written during the config stage and that they are read back afterward?

    Best,

    Alex

  • This is my write and read back of the first three registers, the waveforms look correct, but the read back always go back to default value.

  • Hi,

    Thanks for this info. I will test one more thing on my end and get back to you.

    Best,

    Alex

  • Hi Alex,

    This is my configuration.cpp.

    #include "OPT3101device.h"
    /* OPT3101 device initialization Sequence Header file written by OPT3101 Calibration tool - Version 0.8.0
    By: a0875461
    On: 2018-05-29 23:53:47
    Configuration Settings:
    {
    	"genDeviceI2CMasterTempSensorAddress": 0,
    	"superHDRMode": true,
    	"genDeviceEEPROMConnection": true,
    	"genDeviceI2CMasterConnection": 1,
    	"autoHDRMode": true,
    	"toolVersion": 0.8.0,
    	"superHDRHThreshold": 26000,
    	"genDeviceI2CMasterTempSensorMode": tmp102,
    	"monoshotMode": false,
    	"genDeviceAmbientSupport": 4,
    	"crc": 448535433,
    	"freqRefClock": 125000,
    	"superHDRRatio": 64.0,
    	"genDeviceSubFrameCount": 32,
    	"user": a0875461,
    	"genDeviceAvgFrameCount": 4,
    	"timeStamp": 2018-05-29 23:53:25,
    	"genDeviceI2CMasterTempSensor": true,
    	"freqComp": true,
    	"superHDRTXCurrent": 0,
    	"superHDRTXDCBias": 0,
    }
    */
    void OPT3101::device::initialize(){
    	// List of registers to initialize OPT3101 device after power-up
    
    	this->reg.force_en_slave = 1; // //Since I2C Master bus is floating this register needs to be set to enable device to respond
    
    	this->reg.tg_ovl_window_start = 7000; // //Overload flab observation window
    	this->reg.en_temp_conv = 1; // //Enables the internal
    
    	this->reg.config_tillum_msb = 8; // //Mode select between temp sensors
    	this->reg.en_tillum_12b = 1; // //Chooses between 12bit or 8 bit mode
    	this->reg.en_tillum_read = 1; // //Enable Ext temp sensor read
    	this->reg.temp_avg_illum = 0; // //Sets number of average for ext temp sensor measurement
    	this->reg.frame_vd_trig = 1; // //Trigger temp sensor measurement every VD
    	this->reg.i2c_en = 1;
    	this->reg.i2c_num_tran = 0; // //not required since default is correct
    	this->reg.i2c_rw = 1;
    	this->reg.i2c_num_bytes_tran1 = 1; ///<
    
    	this->reg.tsens_slave0 = 0x48; // //I2C Address for External Temp sensor for TX0 in super HDR Mode
    	this->reg.tsens_slave1 = 0x48; // //I2C Address for External Temp sensor for TX1 in super HDR Mode
    
    	this->reg.clip_mode_fc = 1; // //Enables Clip mode for Frequency correction
    	this->reg.clip_mode_temp = 0; // //Disables Clip mode for Temp coff phase correction
    	this->reg.clip_mode_offset = 0; // //Disables Clip mode for phase offset correction
    	this->reg.iq_read_data_sel = 3; // //Enables 16 bit frame counter
    	this->reg.iamb_max_sel = 12; // //Sets maximum ambient support
    	this->reg.en_temp_corr = 1; // //Enables Temperature Correction
    	this->reg.gpio1_obuf_en=1; // //Enabled output buffer on GPIO1 pin
    	this->reg.gpo1_mux_sel=2; 	    // //select dig_gpo_0 on gpio1
    	this->reg.dig_gpo_sel0 = 9; 	// //Select Data Ready on dig_gpo_0
    
    //	this->reg.en_cont_fcalib=1; // //Enables continuous frequency calibration
    //	this->reg.start_freq_calib=1; // //Starts the frequency calibration block
    //	this->reg.en_floop=1; // //Enables the frequency correction loop
    //	this->reg.en_auto_freq_count=1; // //Enables automatic frequency count
    //	this->reg.en_freq_corr=1; // //Enables digital frequency correction
    //	this->reg.sys_clk_divider = 8;  // //Divider for system clock
    //	this->reg.ref_count_limit = 20480; // //Counter limit
    //	this->reg.gpio2_obuf_en=0; // //Disables output buffer on GPIO2
    //	this->reg.gpio2_ibuf_en=1; // //Enables ref clock input of GPIO2
    
    	this->reg.num_sub_frames = 31; // //Sub frames count
    	this->reg.num_avg_sub_frames = 31; // //Average frames count
    	this->reg.xtalk_filt_time_const = 5; // //Crosstalk filter time constant
    	this->reg.tg_seq_int_start 	= 9850; // //Sequence Start
    	this->reg.tg_seq_int_end 		= 9858; // //Sequence End
    	this->reg.tg_seq_int_mask_start 	= 31; // //Same as AvgFrame Count
    	this->reg.tg_seq_int_mask_end 	= 31; // //Same as AvgFrame Count
    
    	this->reg.en_processor_values = 1; // //Enables processor values
    	this->reg.en_sequencer = 1; // //Enables the Sequencer
    	this->reg.command0 = 0x108; // //Set Channel 1
    	this->reg.command1 = 0xB02; // //COMP1.
    	this->reg.command2 = 0x100; // //Set Channel 0
    	this->reg.command3 = 0xC00; // //COMP1_INV
    	this->reg.compare_reg1 = 26000; // //ThresholdH
    	this->reg.compare_reg2 = 4312; // //ThresholdH
    	this->reg.mux_sel_compin = 0; // //Selects Amplitude for Comparison
    	this->reg.en_tx1_on_tx0 = 1; // //Setting TX1 register and connect to TX0
    
    	this->reg.hdr_thr_high = 25500; // //High Threshold
    	this->reg.hdr_thr_low = 4812; // //Low Threshold
    	this->reg.en_adaptive_hdr = 1; // //Enables adaptive HDR feature
    
    	this->reg.illum_dac_h_tx0 = 2; // //High Current settings [011.2mA:5.6mA X 02]
    	this->reg.illum_scale_h_tx0 = 0; // //Illum scale for H [011.2mA:5.6mA X 02]
    
    	this->reg.illum_dac_l_tx0 = 1; // //High Current settings [002.8mA:2.8mA X 01]
    	this->reg.illum_scale_l_tx0 = 2; // //Illum scale for H [002.8mA:2.8mA X 01]
    
    	this->reg.illum_dac_h_tx1 = 31; // //High Current settings [173.6mA:5.6mA X 31]
    	this->reg.illum_scale_h_tx1 = 0; // //Illum scale for H [173.6mA:5.6mA X 31]
    
    	this->reg.illum_dac_l_tx1 = 31; // //High Current settings [043.4mA:1.4mA X 31]
    	this->reg.illum_scale_l_tx1 = 3; // //Illum scale for H [043.4mA:1.4mA X 31]
    
    	this->reg.tg_en = 1; // //Enables Timing Generator
    
    	this->configurationFlags_xtalkFilterTau =  5; // //This is not a register but a settings flag for the SDK
    	this->configurationFlags_monoshotMode =  false; // //This is not a register but a settings flag for the SDK
    	this->configurationFlags_xtalkSettlingOneTauInMilliSeconds      =  256; // //This is not a register but a settings flag for the SDK
    	this->configurationFlags_xtalkSettlingOneTauInDataReadyCounts   =  32; // //This is not a register but a settings flag for the SDK
    	this->configurationFlags_frameTimeInMilliSeconds                =  8; // //This is not a register but a settings flag for the SDK
    	this->configurationFlags_avgFrameCountExponentOfTwo             =  5; // //This is not a register but a settings flag for the SDK
    
    }
    
    OPT3101::device::device():
    configurationFlags_isTXChannelActive{true,false,false},
    configurationFlags_isRegisterSetActive{true,true} {this->calibration = new calibrationC[1];}
    
    OPT3101::calibrationC::calibrationC() : calibrationC(true) {
    	this->recordLength           = 4; // //This configuration requires 4 crosstalk and other configuration record(s)
    	this->internalCrosstalk      = new OPT3101::crosstalkC[1]; // //This configuration requires 1 internal crosstalk record(s)
    	this->illumCrosstalk         = new OPT3101::crosstalkC[4];   // //This configuration requires 4 internal crosstalk record(s)
    	this->phaseOffset            = new OPT3101::phaseOffsetC[4]; // //This configuration requires 4 internal crosstalk record(s)
    	this->illumCrosstalkTempCoff = new OPT3101::crosstalkTempCoffC[4]; // //This configuration requires 4 internal crosstalk record(s)
    	this->phaseTempCoff          = new OPT3101::phaseTempCoffC[4]; // //This configuration requires 4 internal crosstalk record(s)
    	this->phaseAmbientCoff       = new OPT3101::phaseAmbientCoffC[1]; // //This configuration requires 1 internal crosstalk record(s)
    	this->registerAddressListSize= 36; // //This configuration requires 36 registers [1152] bits to be stored for calibration
    	this->registerAddressList    = new uint8_t[this->registerAddressListSize]; // //Allocation of memory to store register addresses
    	this->EEPROM_connected       =  false; // //This configuration helps configure EEPROM
    	this->extTempSensor_connected=  true; // //This configuration helps configure Ext temp sensor
    	this->registerAddressList[0] = 0x2f; // //Address for register(s) iphase_xtalk_reg_hdr0_tx0,temp_coeff_main_hdr1_tx1
    	this->registerAddressList[1] = 0x30; // //Address for register(s) qphase_xtalk_reg_hdr0_tx0,temp_coeff_main_hdr1_tx1
    	this->registerAddressList[2] = 0x38; // //Address for register(s) temp_coeff_xtalk_iphase_hdr0_tx0
    	this->registerAddressList[3] = 0x39; // //Address for register(s) temp_coeff_xtalk_qphase_hdr0_tx0
    	this->registerAddressList[4] = 0x42; // //Address for register(s) phase_offset_hdr0_tx0
    	this->registerAddressList[5] = 0x47; // //Address for register(s) tmain_calib_hdr0_tx0,tillum_calib_hdr0_tx0
    	this->registerAddressList[6] = 0x45; // //Address for register(s) temp_coeff_main_hdr0_tx0
    	this->registerAddressList[7] = 0x46; // //Address for register(s) temp_coeff_illum_hdr0_tx0
    	this->registerAddressList[8] = 0x31; // //Address for register(s) iphase_xtalk_reg_hdr1_tx0
    	this->registerAddressList[9] = 0x32; // //Address for register(s) qphase_xtalk_reg_hdr1_tx0
    	this->registerAddressList[10] = 0x5e; // //Address for register(s) temp_coeff_xtalk_iphase_hdr1_tx0,temp_coeff_xtalk_iphase_hdr0_tx1
    	this->registerAddressList[11] = 0x60; // //Address for register(s) temp_coeff_xtalk_qphase_hdr1_tx0,temp_coeff_xtalk_qphase_hdr0_tx1,temp_coeff_xtalk_qphase_hdr1_tx1
    	this->registerAddressList[12] = 0x51; // //Address for register(s) phase_offset_hdr1_tx0,temp_coeff_illum_hdr1_tx0
    	this->registerAddressList[13] = 0x48; // //Address for register(s) tmain_calib_hdr1_tx0,tillum_calib_hdr1_tx0
    	this->registerAddressList[14] = 0x2d; // //Address for register(s) temp_coeff_main_hdr1_tx0,temp_coeff_main_hdr0_tx1
    	this->registerAddressList[15] = 0x52; // //Address for register(s) temp_coeff_illum_hdr1_tx0,phase_offset_hdr0_tx1
    	this->registerAddressList[16] = 0x33; // //Address for register(s) iphase_xtalk_reg_hdr0_tx1
    	this->registerAddressList[17] = 0x34; // //Address for register(s) qphase_xtalk_reg_hdr0_tx1
    	this->registerAddressList[18] = 0x49; // //Address for register(s) tmain_calib_hdr0_tx1,tillum_calib_hdr0_tx1
    	this->registerAddressList[19] = 0x53; // //Address for register(s) temp_coeff_illum_hdr0_tx1,phase_offset_hdr1_tx1
    	this->registerAddressList[20] = 0x54; // //Address for register(s) temp_coeff_illum_hdr0_tx1
    	this->registerAddressList[21] = 0x35; // //Address for register(s) iphase_xtalk_reg_hdr1_tx1
    	this->registerAddressList[22] = 0x36; // //Address for register(s) qphase_xtalk_reg_hdr1_tx1
    	this->registerAddressList[23] = 0x5f; // //Address for register(s) temp_coeff_xtalk_iphase_hdr1_tx1
    	this->registerAddressList[24] = 0x41; // //Address for register(s) tmain_calib_hdr1_tx1
    	this->registerAddressList[25] = 0x43; // //Address for register(s) tillum_calib_hdr1_tx1,en_phase_corr,en_temp_corr,scale_phase_temp_coeff
    	this->registerAddressList[26] = 0x55; // //Address for register(s) temp_coeff_illum_hdr1_tx1
    	this->registerAddressList[27] = 0x56; // //Address for register(s) temp_coeff_illum_hdr1_tx1
    	this->registerAddressList[28] = 0x2e; // //Address for register(s) illum_xtalk_reg_scale
    	this->registerAddressList[29] = 0x3a; // //Address for register(s) scale_temp_coeff_xtalk
    	this->registerAddressList[30] = 0x71; // //Address for register(s) shift_illum_phase
    	this->registerAddressList[31] = 0xb5; // //Address for register(s) scale_amb_phase_corr_coeff
    	this->registerAddressList[32] = 0x0c; // //Address for register(s) amb_phase_corr_pwl_coeff0
    	this->registerAddressList[33] = 0xb4; // //Address for register(s) amb_phase_corr_pwl_coeff1,amb_phase_corr_pwl_coeff2,amb_phase_corr_pwl_coeff3
    	this->registerAddressList[34] = 0xb8; // //Address for register(s) amb_phase_corr_pwl_x0,amb_phase_corr_pwl_x1
    	this->registerAddressList[35] = 0xb9; // //Address for register(s) amb_phase_corr_pwl_x2
    
    }
    
    

  • Hi,

    I checked using your config and I was able to configure the device and perform crosstalk calibration.

    Also I noticed glitches on the I2C waveform you sent. Could this be causing issues and do you know where the glitches come from?

    This seems to be an issue in your i2c read/write as far as I can tell. Please let me know if there are any other tests you think would be helpful to run if we need to narrow this down further. The latest update to the SDK we are about to release can run on a TI MSP launchpad if this would be helpful for you to get it running on known hardware or as a first step in debugging the issue on your system.

    Best,

    Alex

  • Hi Alex,

    Thank you for your checking.

    I guess there might be problem with my hardware. Let me fabricate another piece of sensor board and try again.

  • Hi,

    Do you know what the problem was. We have a lot of layout guidelines in our system design doc so if you are spinning a new board wanted to mention to make sure you get the best performance. If you share layout/schematic I can also check your design for you before you rebuild.

    Additionally, we have a further layout recommendation to improve performance that involves putting -5V instead of photodiode ground. -3.3V also works if 5V supply is not present. If you would like to add to your new board, I have attached below

    Best,

    Alex

  • Hi Alex,

    I tested another board it is ok.

    I will make some changes next time like adding a pull-up at the reset etc.

    Thank you very much.

  • Good to hear. I will mark this post resolved.

    Best,

    Alex