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

Getting "0" on TWI peripheral with ble_app_uart / softdevice s132

Hi,

I want to capture data from TWI ADXL345 and send them by ble_nus_data_send() to mobile. Timing of data sending is done by application timer. My problem is that when i run my code with debugger, i can cee data from ADXL345 are also "0". TWI is enabled in config.h. I thing it would be problem with softdevice and TWI. Using Segger embedded studio with nRF52832, sd132, SDK 15.3 and ADXL345 library from https://devzone.nordicsemi.com/f/nordic-q-a/10841/i2c-in-nrf51-sdk/40520#40520 written by bjorn-spockeli. Please see atached code.

regards

static void data_send()
{
  //accel_data();
  uint32_t       err_code;
  uint8_t   x = avgvalX ; // problem ve formatu
  SEGGER_RTT_printf(0,"%d\n",avgvalX);
  unsigned char  buf[20]; //ASCII znaky
  unsigned char buff_send[20];
  //unsigned char ble_data[20];

  snprintf(buf, sizeof(buf),"%d", x);
  //SEGGER_RTT_printf(0,"%c\n",buf[2]);
      
     for(uint8_t i = 0; i < 3; i++){
            buff_send[i] = buf[i] - '0' + 48; // char to integer conversion // +48 ASCII coding
            //SEGGER_RTT_printf(0,"%d\n",buff_send[i]);
            //nrf_delay_ms(200);
            }


      //static uint16_t length = sizeof(buf);
      static uint16_t length = 3;
      err_code =   ble_nus_data_send(&m_nus, buff_send, &length, m_conn_handle);
      //SEGGER_RTT_printf(0,"%d\n",avgvalX);
      
         if ( (err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY) &&
                         (err_code != NRF_ERROR_NOT_FOUND) )
                    {
                        APP_ERROR_CHECK(err_code);
                    }

        //NRF_LOG_INFO("Value Received !");

}


static void repeated_timer_handler(void * p_context)
{
    //timer handler for app_timer_diff_compute()
}

static void repeated_timer_BLE(void * p_context)
{
  data_send();
  SEGGER_RTT_printf(0,"print me\n");
}

Related