Hello all,
I am trying to implement TDC-GP22 time of flight sensor using Arduino UNO. I am using one Github code for this module, but SPI communication between the Arduino and GP22 does not work. The specific questions are after the code. The code link as follows:
I have already checked wiring between the Arduino and GP22, as following the configuration in the source code. Even if I am a newbie for the SPI coding, I tracked the code to narrow an error range, and found some weird things:
-
The variable 'DEBUG' in the code is set '0', which means the serial baud rate should be 1000000, not 115200. So I myself change DEBUG from '0' to '1', but reading does not work. Should I set DEBUG to '0' back?
-
Tracking the error, I found that 'tdc_testcommunication()' does not work. -> In testcommunication() function in GP22.cpp, 'readRegister' does not work. -> 'readNByte' does not work. -> 'SPI.transfer' does not work.
Actually, SPI.transfer is an inherited function in the Arduino.ino library. To deep inside to this function, I realized that 'SPDR' variable does not change; it always set '0'. How can I solve this issue?
Since the datasheet is too large, I attach its link here:
TDC-GP22 datasheet link
I attach GP22 application and its source code. Thank you all!
TDC-GP22_AN000249_1-00.pdf (1.37 MB)
TDCtalk.ino (9.05 KB)