The accelerometer and the magnetometer have separate 7-bit slave addresses on the
I2C bus. The magnetometer’s slave address is 0011110b and cannot be changed. The accelerometer’s slave address has its least significant bit (LSb) determined by the voltage on the slave address selector pad (SA0_A). The carrier board pulls SA0_A to ground through a 4.7kΩ resistor, setting the accelerometer’s slave address to 0011000b by default. If the accelerometer’s selected slave address happens to conflict with some other device on your
I2C bus, it is possible to access SA0_A through the untented via on the bottom of the board and pull it up. In our tests of the board, we were able to communicate with the chip at clock frequencies up to 400 kHz.
Also ist die Adresse:
Dirk hat gesagt ich soll mal den Script versuchen:
Code:
/*
* ****************************************************************************
* RP6 ROBOT SYSTEM - RP6 CONTROL M32 Examples
* ****************************************************************************
* Example: RP6Control LSM303DLM magnetometer test
* Author(s): Dirk
* ****************************************************************************
* Description:
* In this example we show a test for the LSM303DLM magnetometer.
*
* ############################################################################
* The Robot does NOT move in this example! You can simply put it on a table
* next to your PC and you should connect it to the PC via the USB Interface!
* ############################################################################
* ****************************************************************************
*/
/*****************************************************************************/
// Includes:
#include "RP6ControlLib.h" // The RP6 Control Library.
// Always needs to be included!
#include "RP6I2CmasterTWI.h" // Include the I2C-Bus Master Library
/*****************************************************************************/
// I2C Error handler
/**
* This function gets called automatically if there was an I2C Error like
* the slave sent a "not acknowledge" (NACK, error codes e.g. 0x20 or 0x30).
* The most common mistakes are:
* - using the wrong address for the slave
* - slave not active or not connected to the I2C-Bus
* - too fast requests for a slower slave
* Be sure to check this if you get I2C errors!
*/
void I2C_transmissionError(uint8_t errorState)
{
writeString_P("\nI2C ERROR --> TWI STATE IS: 0x");
writeInteger(errorState, HEX);
writeChar('\n');
}
/*****************************************************************************/
// Main function - The program starts here:
int main(void)
{
initRP6Control(); // Always call this first! The Processor will not
// work correctly otherwise.
initLCD(); // Initialize the LC-Display (LCD)
// Always call this before using the LCD!
setLEDs(0b1111);
mSleep(500);
setLEDs(0b0000);
writeString_P("\n\nRP6Control LSM303DLM Test 1!\n");
// IMPORTANT:
I2CTWI_initMaster(100); // Initialize the TWI Module for Master operation
// with 100kHz SCL Frequency
// Register the event handler:
I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);
setLEDs(0b1111);
// Write a text message to the LCD:
showScreenLCD("################", "################");
mSleep(1500);
showScreenLCD(" RP6Control M32", "Example Program");
mSleep(2500);
showScreenLCD(" LSM303DLM", " Test 1");
mSleep(2500);
clearLCD();
setLEDs(0b0000);
// ---------------------------------------
uint8_t daten[6];
startStopwatch1();
while(true)
{
if(getStopwatch1() > 1000) // 1s
{
I2CTWI_transmitByte(0011110b, 0xEE);
I2CTWI_readBytes(0011110b, daten, 6);
writeString_P("Daten: ");
writeInteger(daten[0], DEC);
writeInteger(daten[1], DEC);
writeInteger(daten[2], DEC);
writeInteger(daten[3], DEC);
writeInteger(daten[4], DEC);
writeInteger(daten[5], DEC);
writeChar('\n');
setStopwatch1(0);
}
task_I2CTWI();
}
return 0;
}
wenn ich die Adresse 0011110b einsetze giebt es einen fehler wegen dem B.
und was muss ich für einen Wert senden?
Bin ich Blind? 
LG
Lesezeichen