Magelan1979
06.05.2010, 20:04
Schönen guten Abend. Ich habe da ein Problem. Da ich gerne die M128 als Master verwenden wollte, hatte ich vor, die Base wie auch die M32 als Slave zu verwenden. Die Kommunikation zwischen der Base und der M128 funktioniert einwandfrei. Ebenso kann ich auch als Master z.B. das LC-Display welches an der M32 angeschlossen ist ansprechen. Was allerdings nicht funktioniert ist, die automatische Übertragung der M32-Sensorwerte an das M128, wie es ja von der Base nach der M128 funktioniert.
Ich versuche mal die entsprechenden Stellen des Quellcodes zu identifizieren:
M32:
#define RP6Control_I2C_SLAVE_ADR 20
#define I2C_GETMICROPHONEPEAK 1
#define I2C_BUTTON 2
#define I2C_ADC_2 3
#define I2C_ADC_3 4
#define I2C_ADC_4 5
#define I2C_ADC_5 6
#define I2C_ADC_6 7
#define I2C_ADC_7 8
/**
* This very important function updates ALL registers that the Master can read.
* It is called frequently out of the Main loop.
*/
void task_updateRegisters(void)
{
if(!I2CTWI_readBusy)
{
I2CTWI_readRegisters[I2C_GETMICROPHONEPEAK] = 88;// (uint16_t)(getMicrophonePeak());
I2CTWI_readRegisters[I2C_BUTTON] = 99;// (uint8_t)(99);//getPressedKeyNumber());
I2CTWI_readRegisters[I2C_ADC_2] = 77;// (uint16_t)readADC(ADC_2);
I2CTWI_readRegisters[I2C_ADC_3] = 66;// (uint16_t)readADC(ADC_3);
I2CTWI_readRegisters[I2C_ADC_4] = 55;// (uint16_t)readADC(ADC_4);
I2CTWI_readRegisters[I2C_ADC_5] = 44;// (uint16_t)readADC(ADC_5);
I2CTWI_readRegisters[I2C_ADC_6] = 33;// (uint16_t)readADC(ADC_6);
I2CTWI_readRegisters[I2C_ADC_7] = 22;// (uint16_t)readADC(ADC_7);
if(I2CTWI_dataWasRead && I2CTWI_dataReadFromReg == 0)
clearInterrupt();
}
}
while(true)
{
task_commandProcessor();
task_updateRegisters();
}
M128:
' M32-Modul_Parameter
Dim I2C_GETMICROPHONEPEAK As Word
Dim I2C_BUTTON As Word
Dim I2C_ADC_2 As Word
Dim I2C_ADC_3 As Word
Dim I2C_ADC_4 As Word
Dim I2C_ADC_5 As Word
Dim I2C_ADC_6 As Word
Dim I2C_ADC_7 As Word
Dim messageBufferM32(8) As Byte
#define CMD_SETLEDS 0
#define CMD_CLEARLCD 1
#define CMD_WRITECHARLCD 2
#define CMD_SHOWSCREENLCD 3
#define CMD_DISCHARGEPEAKDETECTOR 4
#define CMD_BEEP 5
#define CMD_SETBEEPERPITCH 6
#define CMD_MSLEEP 7
#define CMD_WRITE_I_AT_POSITION 8
#define CMD_WRITE_S_AT_POSITION 9
Sub getAllSensorsM32()
RP6_readRegisters(RP6_M32_ADR, 1, messageBufferM32, 8)
I2C_GETMICROPHONEPEAK = messageBufferM32(0)
I2C_BUTTON = messageBufferM32(1)
I2C_ADC_2 = messageBufferM32(2)
I2C_ADC_3 = messageBufferM32(3)
I2C_ADC_4 = messageBufferM32(4)
I2C_ADC_5 = messageBufferM32(5)
I2C_ADC_6 = messageBufferM32(6)
I2C_ADC_7 = messageBufferM32(7)
End Sub
Wenn ich mir die Werte I2C_BUTTON etc. ausgeben lasse erhalte ich immer den Wert 0
Ich baue auf eure Hilfe
Gruß und einen schönen Abend noch.
Magelan
Ich versuche mal die entsprechenden Stellen des Quellcodes zu identifizieren:
M32:
#define RP6Control_I2C_SLAVE_ADR 20
#define I2C_GETMICROPHONEPEAK 1
#define I2C_BUTTON 2
#define I2C_ADC_2 3
#define I2C_ADC_3 4
#define I2C_ADC_4 5
#define I2C_ADC_5 6
#define I2C_ADC_6 7
#define I2C_ADC_7 8
/**
* This very important function updates ALL registers that the Master can read.
* It is called frequently out of the Main loop.
*/
void task_updateRegisters(void)
{
if(!I2CTWI_readBusy)
{
I2CTWI_readRegisters[I2C_GETMICROPHONEPEAK] = 88;// (uint16_t)(getMicrophonePeak());
I2CTWI_readRegisters[I2C_BUTTON] = 99;// (uint8_t)(99);//getPressedKeyNumber());
I2CTWI_readRegisters[I2C_ADC_2] = 77;// (uint16_t)readADC(ADC_2);
I2CTWI_readRegisters[I2C_ADC_3] = 66;// (uint16_t)readADC(ADC_3);
I2CTWI_readRegisters[I2C_ADC_4] = 55;// (uint16_t)readADC(ADC_4);
I2CTWI_readRegisters[I2C_ADC_5] = 44;// (uint16_t)readADC(ADC_5);
I2CTWI_readRegisters[I2C_ADC_6] = 33;// (uint16_t)readADC(ADC_6);
I2CTWI_readRegisters[I2C_ADC_7] = 22;// (uint16_t)readADC(ADC_7);
if(I2CTWI_dataWasRead && I2CTWI_dataReadFromReg == 0)
clearInterrupt();
}
}
while(true)
{
task_commandProcessor();
task_updateRegisters();
}
M128:
' M32-Modul_Parameter
Dim I2C_GETMICROPHONEPEAK As Word
Dim I2C_BUTTON As Word
Dim I2C_ADC_2 As Word
Dim I2C_ADC_3 As Word
Dim I2C_ADC_4 As Word
Dim I2C_ADC_5 As Word
Dim I2C_ADC_6 As Word
Dim I2C_ADC_7 As Word
Dim messageBufferM32(8) As Byte
#define CMD_SETLEDS 0
#define CMD_CLEARLCD 1
#define CMD_WRITECHARLCD 2
#define CMD_SHOWSCREENLCD 3
#define CMD_DISCHARGEPEAKDETECTOR 4
#define CMD_BEEP 5
#define CMD_SETBEEPERPITCH 6
#define CMD_MSLEEP 7
#define CMD_WRITE_I_AT_POSITION 8
#define CMD_WRITE_S_AT_POSITION 9
Sub getAllSensorsM32()
RP6_readRegisters(RP6_M32_ADR, 1, messageBufferM32, 8)
I2C_GETMICROPHONEPEAK = messageBufferM32(0)
I2C_BUTTON = messageBufferM32(1)
I2C_ADC_2 = messageBufferM32(2)
I2C_ADC_3 = messageBufferM32(3)
I2C_ADC_4 = messageBufferM32(4)
I2C_ADC_5 = messageBufferM32(5)
I2C_ADC_6 = messageBufferM32(6)
I2C_ADC_7 = messageBufferM32(7)
End Sub
Wenn ich mir die Werte I2C_BUTTON etc. ausgeben lasse erhalte ich immer den Wert 0
Ich baue auf eure Hilfe
Gruß und einen schönen Abend noch.
Magelan