Go Down

Topic: I2C interface with LIS3LV02DQ (Read 401 times) previous topic - next topic

weinerschizel

I've been trying to get the I2C bus to work with my LIS3LV02DQ.  Using the wire library didn't work.  So I decided to take a lower level approach and use the example code from the Atmega168's datasheet.  Right now the code hangs when polling the interrupt flag.

I'm not really sure if I've even setup the Atmega correctly for I2C.  Here is what my code looks like:

void loop( void )
{
 
 TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);  // Send Start
 while( !(TWCR & (1 << TWINT) ) );  // Wait to receive Slave ACK
 Serial.println( "Slave ACK" );   // Never receives the TWINT flag so this never prints
}

void setup( void )
{
 Serial.begin(9600);
 PRR |= 0x80;          // Turn on TWI
 TWCR |= (1 << TWEN);  // Enable SCL and SDA Pg. 83
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy