I am writing code for an ATtiny25 to interface with a proximity sensor VCNL4200 (slave address 0x51).
The picture you are seeing is 9 clock signals signifying initial slave address along with write bit and NACK. I can't seem to get the response ACK bit I want.
Unfortunately, the ATtiny25 uses USI and has no hardware I2C implementation. I am using the USI_TWI_MASTER.h library provided by Microchip. I feel as though my timings are well within reason as per the datasheet provided by the sensor. I am running in standard, not fast mode I2C.
If someone has run into issues regarding using this library and has advice on how to proceed I would greatly appreciate it.
If you have any comments about the waveforms or issues regarding it I will gladly listen.
There is a snippet of code in the TWI master library:
unsigned char tempUSISR_8bit =
(1 << USISIF) |
(1 << USIOIF) |
(1 << USIPF) |
(1 << USIDC) | // Prepare register value to: Clear flags, and
(0x0 << USICNT0); // set USI to shift 8 bits i.e. count 16 clock edges.
unsigned char tempUSISR_1bit =
(1 << USISIF) |
(1 << USIOIF) |
(1 << USIPF) |
(1 << USIDC) | // Prepare register value to: Clear flags, and
(0xE << USICNT0); // set USI to shift 1 bit i.e. count 2 clock edges.
where the USISR interrupts are cleared by writing 1 to them. I am confused as to why this is the case despite reading the datasheet. If someone could also help me clarify what is going on in these two statements aside from setting the counter I would be grateful.
UPDATE Hi everyone, thank you for the responses,
I've managed to get hold of a eval module with the sensor on it and hooked it up directly to my Attiny. I was successfully able to get Ack bits from this janky setup. Unfortunately the same cannot be said with the sensor directly on my PCB. I will update accordingly.
1010001W
\$\endgroup\$