Hi Marcel,

das Modul CMPS03 wird völlig anders ausgelesen als der HDMM01. Daher kannst du mein Programm nicht 1:1 nehmen.

Ich habe den HDMM01 nicht selbst. Du kannst folgendes Testprogramm mal als Anfang für eigene Experimente nehmen:
Code:
/* 
 * ****************************************************************************
 * RP6 ROBOT SYSTEM - ROBOT BASE EXAMPLES
 * ****************************************************************************
 * Example: I2C Master - HDMM01
 * Author(s): Dirk
 * ****************************************************************************
 * Description:
 *
 * This Example shows how to use the compass module HDMM01
 * with RP6Library.
 *
 * ****************************************************************************
 */
/*****************************************************************************/
// Includes:
#include "RP6RobotBaseLib.h"  

// IMPORTANT:
#include "RP6I2CmasterTWI.h"     // Include the I²C-Bus Slave Library

/*****************************************************************************/
// I2C Event handlers:
/**
 * 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');
}
/*****************************************************************************/
/**
 * Write a long number (with specified base) to the UART.
 *
 * Example:
 *
 *   // Write a hexadecimal number to the UART:
 *   writeLong(0xAACC,16);
 *   // Instead of 16 you can also write "HEX" as this is defined in the
 *   // RP6uart.h :
 *   writeLong(0xAACC, HEX);
 *   // Other Formats:
 *   writeLong(1024,DEC);   // Decimal
 *   writeLong(044,OCT);  // Octal
 *   writeLong(0b11010111,BIN); // Binary
 */
void writeLong(int32_t number, uint8_t base)
{char buffer[33];
 ltoa(number, &buffer[0], base);
 writeString(&buffer[0]);
}
/*****************************************************************************/
// The I2C slave address of the compass module HDMM01 is 0x60:
#define HDMM01_ADR  0x60
// HDMM01 Data Register:
#define DATA_REG  0
// HDMM01 Commands:
#define SET_COIL  0b00000010
#define RESET_COIL  0b00000100
#define MEASURE   0b00000001
uint8_t results[5];
/**
 * READ HDMM01 DATA REGISTER
 *
 * This function reads the data register of the HDMM01.
 *
 */
void readHDMM01(void)
{
 I2CTWI_transmit2Bytes(HDMM01_ADR, DATA_REG, SET_COIL);
 mSleep(1);
 I2CTWI_transmit2Bytes(HDMM01_ADR, DATA_REG, RESET_COIL);
 mSleep(5);
 I2CTWI_transmit2Bytes(HDMM01_ADR, DATA_REG, MEASURE);
 mSleep(5);
 I2CTWI_transmitByte(HDMM01_ADR, DATA_REG);
 // Hier sollte eigentlich kein Stop sein ...
 I2CTWI_readBytes(HDMM01_ADR, results, 5);
 return;
}
/**
 * HDMM01 TASK
 *
 * This is the HDMM01 task.
 *
 */
void task_HDMM01(void)
{uint16_t X, Y;
 if (getStopwatch1() > 500) {
  readHDMM01();
  results[1] = results[1] & 0b00001111;
  results[3] = results[3] & 0b00001111;
  X = results[1] * 256;
  X = X + results[2];
  Y = results[3] * 256;
  Y = Y + results[4];
  writeString_P("XY: "); 
  writeLong(X, DEC);
  writeChar(' ');
  writeLong(Y, DEC);
  writeString_P(" \n");
  setStopwatch1(0);
 }
}
/*****************************************************************************/
// Main - The program starts here:
int main(void)
{
 initRobotBase();
 
 I2CTWI_initMaster(100); // Initialize the TWI Module for Master operation
       // with 100kHz SCL Frequency
 
 // Register the event handlers:
 I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);
 setLEDs(0b111111);
 mSleep(500);    
 setLEDs(0b000000);
 
 powerON();
 startStopwatch1();
 
 while(true)  
 {
  task_HDMM01();
  task_I2CTWI();
  task_RP6System();
 }
 return 0;
}
/******************************************************************************
 * Additional info
 * ****************************************************************************
 * Changelog:
 * - v. 1.0beta (initial release) 04.03.2012 by Dirk
 *
 * ****************************************************************************
 */
/*****************************************************************************/
Ein Problem bei der Lesefunktion ist, dass an einer Stelle (siehe Kommentar) eigentlich kein Stop gesendet werden darf. Das macht aber die RP6 Library.
Aber: Probier das doch erst einmal.