This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

we can't read all bytes from TWIS

Hi
We are making a project where we use Bluetooth mesh, which works fine, but we have a problem with TWI (slave), the problem is when we want to read what is  on the slave where we would like to read 3 bytes , but when we read we only get first and last bytes
Here is our code snip

 uint8_t buftest[1];
        uint8_t count = 0;

        // Sen8d number of nodes
        buftest[0] = 1;                                                                                                        //bufNodeTX[0];
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "tx_buff nodecount  %u  \n", /*buftest[0+count], buftest[1+count],*/ bufNodeTX[0]); //,bufNodeTX[1+count],buftest[2+count]);
        nrf_drv_twis_tx_prepare(&instance, buftest, sizeof(buftest));

        do {
          if ((count % 2) == 0) {
            if (!nrf_drv_twis_is_waiting_tx_buff(&instance) && !nrf_drv_twis_is_busy(&instance) && !nrf_drv_twis_is_pending_tx(&instance)) {
              int firstbyte[1];
              firstbyte[0] = 0b00011011; // bufNodeTX[count+1];
              //__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "tx_buff firstnodedata  %u  \n",/*buftest[0+count], buftest[1+count],*/bufNodeTX[count+1]);//,bufNodeTX[1+count],buftest[2+count]);
              __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "tx_buff firstnodedata  %u count: %u \n", firstbyte[0], count);
              nrf_drv_twis_tx_prepare(&instance, firstbyte, sizeof(firstbyte));
              count++;
              //nrf_delay_us(500);
            }
          } else {
            if (!nrf_drv_twis_is_waiting_tx_buff(&instance) && !nrf_drv_twis_is_busy(&instance) && !nrf_drv_twis_is_pending_tx(&instance)) {
              int secondbyte[1];
              secondbyte[0] = 0b00100000; // bufNodeTX[count+1];
              //__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "tx_buff secondnodedata  %u  \n",/*buftest[0+count], buftest[1+count],*/bufNodeTX[count+1]);//,bufNodeTX[1+count],buftest[2+count]);
              __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "tx_buff secondnodedata  %u count: %u \n", secondbyte[0], count);
              nrf_delay_us(500);
              nrf_drv_twis_tx_prepare(&instance, secondbyte, sizeof(secondbyte));
              count++;
            }
          }
        } while (count != (m_configured_devices * 2));

where we have been inspire by this page http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.2.0%2Fhardware_driver_twis_slave.html&cp=4_0_0_2_17

but we have an idea that the middle byte will be overwritten before it is sent, we don't now if it is right , so we would hear if there is somebody has an idea of what to do to read all 3 bytes instead of the 2 bytes .

Related