Hi,
I'm trying to add a second slave twi device to the twi_sensor example with the LM75B temperature sensor but am having trouble. I am using the bmd-300 evaluation kit. I tried searching for similar information but I couldn't find any that answers my question.
I created code for an accelerometer slave device following the format of the twi_sensor example by creating a new slave set_mode function and a new read slave function. I was still using the same TWI instance, SCL, and SDA lines and got the temperature and accelerometer working individually, that is I had two sets of code for each slave device and got both of them to work.
In uart I would get this with one slave device I get an output like this
APP:INFO:
TWI sensor example
APP:INFO:
APP:INFO:Temperature: 30 Celsius degrees.
APP:INFO:Temperature: 30 Celsius degrees.
Then I tried merging the two but could not get it to work. This was the change I was attempting
NRF_LOG_INFO("\r\nTWI sensor example\r\n");
NRF_LOG_FLUSH();
twi_init();
LM75B_set_mode(); // set up temperature
// Added code in main
nrf_delay_ms(500); // not sure if needed or needs to be this long
MM865_set_mode(); // set up accel
When attempting to set_mode for both devices but only output temperature or accel data I get this
APP:INFO:
TWI sensor example
APP:INFO:
▒*II=I2▒х▒5
APP:INFO:
TWI sensor example
APP:INFO:
▒*II=I2▒х▒5
APP:INFO:
TWI sensor example
APP:INFO:
Can someone help me understand why this is happening? By the repeating "TWI sensor example" it must be re-starting main over and over but I don't understand why?
I'm not even trying to read data from both device at this point but just setting the mode for both. As I understand TWI, I should be able to use the same TWI instance
static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(0);
and the same SDA and SCL to interact with both slave devices. Where am I going wrong?