Open KingZuluKing opened 3 years ago
In your example code, you have the following line:
// i2cSend(0x01); // send address of lowbyte
That refers to the wrong address. The correct address would be 0x10:
// i2cSend(0x10); // send address of lowbyte
Hello Brad, Thanks for the feedback. I have changed, and rewritten some part of the code and we get now stable data from LIDAR Lite v3HP.
But there is one thing which seems to be unclear to me in the code below. There are some debug printouts in between to follow each transaction on i2C. When I use this code below to poll status, everything is okay, and I can see what status LIDAR Lite currently has. But when I remove these debug printouts, then this code starts tells me LIDAR Lite is Busy all the time. If I turn back on the debug printouts then it start working properly. Any ideas what could be a reason for that behavior.
David
uint8_t check_LIDAR_busyFlag(void){
uint8_t receiver_reply;
uint8_t status_register = 0;
i2cStart(); // start a session on the i2C BUS
i2cSend(0b11000100); // write operation on LIDAR
receiver_reply = TWSR; // read twi status code
receiver_reply = (receiver_reply & 0b11111000); // mask the lower 3 bits
if(receiver_reply == TW_MT_SLA_ACK){ // if LIDAR sent Ack! proceed to next step
printString("issuing address + write bit >> ok!, device accessible\r\n");
printBinaryByte(receiver_reply); // return the upper 5 bits for check-up
printString("\r\n");
i2cSend(0b00000001); // sending LIDAR status register address here
receiver_reply = TWSR; // read twi status code
receiver_reply = receiver_reply & 0b11111000; // mask the lower 3 bits
if(receiver_reply == TW_MT_DATA_ACK){ // if LIDAR sent Ack! proceed to next step
printString("register 0x01 address sent >> ok!\r\n");
printBinaryByte(receiver_reply); // return the upper 5 bits for check-up
printString("\r\n");
i2cStop(); // stop i2C session
}
}
printString("i am here");
printString("\r\n");
i2cStart(); // start a i2C session again
i2cSend(0b11000101); // send LIDAR address and read bit
receiver_reply = TWSR; // read twi status code
receiver_reply = receiver_reply & 0b11111000; // mask the lower 3 bits
printBinaryByte(receiver_reply); // return the upper 5 bits for check-up
printString("\r\n");
if(receiver_reply == TW_MR_SLA_ACK){ // if LIDAR sent Ack! proceed to next step
printString("issuing address + read bit >> ok!, device accessible ------\r\n");
printBinaryByte(receiver_reply); // return the upper 5 bits for check-up
printString("\r\n");
status_register = i2cReadNoAck();
printString("\r\nLIDAR-STATUS = ");
printBinaryByte(status_register);
printString("\r\n");
}
return(status_register);
}
Dear all, We are interfacing the Garmin LIDAR-LITE V3HP with our hardware and using the datasheet to send the i2C commands to make a distance measurements. We use ATmega1284p AVR as Host MCU.
It seems that what we receive is garbage, and/or not correct measurement data. Below is the i2C session which we initiate with device. Any information regarding the i2C transaction and its commands being sent to achieve the correct data will be highly appreciated.... David