Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 7 months ago.
i2cslaveとi2cmasterの同時利用について
NUCLEO-F401REでマスターからi2cslaveで受信したデータを加工して別のスレーブに送信したいのですが
このように
I2C i2c(D3, D6); // sda, scl I2CSlave slave(D14, D15);
宣言した時点で動作しなくなります
接続は マスター(XMOS)からF401REのi2cSlave F401REのi2cマスターからアイソレータ経由でDAC(AKM AK4490)とつながっています
SoftwareI2Cでは問題なく動くのですが動作速度の問題か取りこぼしやフリーズが多発しています。
そもそもこの二つは同時に使用できないのでしょうか?
動作しないコード
#include "mbed.h"
I2C i2c(D3, D6); // sda, scl
I2CSlave slave(D14, D15);
const int addr = 0x11<<1; // define the I2C Address
int main()
{
char buf[2];
int i;
slave.address(addr);
i2c.frequency(400000);
while (1) {
i = slave.receive();
switch (i) {
case I2CSlave::WriteAddressed:
slave.read(buf, 2);
i2c.write(addr, buf, 2);
slave.stop();
break;
}
}
}