<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Usıng TWI with BLE nRF52dk</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/73830/us-ng-twi-with-ble-nrf52dk</link><description>I am trying to make ble communication work with I2C but i cant make it work i dont understand what is the issue the code is being build but it does not advertise can someone help me or show an example for me to work with i cant find any good examples</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 14 Apr 2021 19:32:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/73830/us-ng-twi-with-ble-nrf52dk" /><item><title>RE: Usıng TWI with BLE nRF52dk</title><link>https://devzone.nordicsemi.com/thread/304930?ContentTypeID=1</link><pubDate>Wed, 14 Apr 2021 19:32:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c4c25ba-0b7d-48cc-9654-16dadaea1cdb</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Event type (decimal) 87 is 0x57, and if you look at ble_ranges.h you can find it&amp;#39;s a&amp;nbsp;BLE_GATTS_EVT_BASE event. If you open ble_gatts.h you can find all events that start from&amp;nbsp;&lt;span&gt;BLE_GATTS_EVT_BASE:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;enum BLE_GATTS_EVTS
{
  BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE,       /**&amp;lt; Write operation performed.                                           \n See @ref ble_gatts_evt_write_t.                 */
  BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST,             /**&amp;lt; Read/Write Authorization request.                                    \n Reply with @ref sd_ble_gatts_rw_authorize_reply. \n See @ref ble_gatts_evt_rw_authorize_request_t. */
  BLE_GATTS_EVT_SYS_ATTR_MISSING,                 /**&amp;lt; A persistent system attribute access is pending.                     \n Respond with @ref sd_ble_gatts_sys_attr_set.     \n See @ref ble_gatts_evt_sys_attr_missing_t.     */
  BLE_GATTS_EVT_HVC,                              /**&amp;lt; Handle Value Confirmation.                                           \n See @ref ble_gatts_evt_hvc_t.                   */
  BLE_GATTS_EVT_SC_CONFIRM,                       /**&amp;lt; Service Changed Confirmation.                                        \n No additional event structure applies.          */
  BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST,             /**&amp;lt; Exchange MTU Request.                                                \n Reply with @ref sd_ble_gatts_exchange_mtu_reply. \n See @ref ble_gatts_evt_exchange_mtu_request_t. */
  BLE_GATTS_EVT_TIMEOUT,                          /**&amp;lt; Peer failed to respond to an ATT request in time.                    \n See @ref ble_gatts_evt_timeout_t.               */
  BLE_GATTS_EVT_HVN_TX_COMPLETE                   /**&amp;lt; Handle Value Notification transmission complete.                     \n See @ref ble_gatts_evt_hvn_tx_complete_t.       */
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This means 0x57 is&amp;nbsp;BLE_GATTS_EVT_HVN_TX_COMPLETE, and the notification have been sent with success (yay!). I guess you need to look at the handle, data and length you tried to pass to sd_ble_gatts_hvx(), and why that was random?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usıng TWI with BLE nRF52dk</title><link>https://devzone.nordicsemi.com/thread/304923?ContentTypeID=1</link><pubDate>Wed, 14 Apr 2021 19:01:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:156e94ea-5d9c-42cf-af4f-bf0997db1e0c</guid><dc:creator>kefom</dc:creator><description>&lt;p&gt;yes you were right the 104 was not an error code but it was the value of mpu who am i result so i just comment the part for&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt; //   err_code=readByte(MPU6050_ADDRESS, ADDRESS_WHO_AM_I);
 //   APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and i checked the results of who am i myself and they are both 104 so thecniquely I2C is working so thanks for that ( i still dont know why it gave error like it was fine when i was using thiss code for just TWI )i still have a problem with BLE tough it sends random data again i am fine with that i didnt give any init_value for that but i cant update it ( change the value as i wish) it gets stuck and says this on logger&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app: In ble_cus_custom_value_update. 

&amp;lt;info&amp;gt; app: sd_ble_gatts_hvx result: 0. 

&amp;lt;info&amp;gt; app: BLE event received. Event type = 87&lt;/pre&gt; do you have any suggestions about this without&amp;nbsp;&lt;span&gt;A logic analyzer because i dont own one and cant go anywhere because of the pandemic&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Efe&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Sorry for taking this much of your time .&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usıng TWI with BLE nRF52dk</title><link>https://devzone.nordicsemi.com/thread/304909?ContentTypeID=1</link><pubDate>Wed, 14 Apr 2021 16:21:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2599fc22-37bd-49bd-a42d-cfd4d81631c4</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;So what code is executing on line 29 of&amp;nbsp;mpu6050.c?&amp;nbsp;Next step would be to find from the&amp;nbsp;API&amp;nbsp;description what the error code 104 may mean. However, I can find from mpu6050.c the following comment:&lt;/p&gt;
&lt;p&gt;#define&amp;nbsp;ADDRESS_WHO_AM_I&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(0x75U)&amp;nbsp;//&amp;nbsp;!&amp;lt;&amp;nbsp;WHO_AM_I&amp;nbsp;register&amp;nbsp;identifies&amp;nbsp;the&amp;nbsp;device.&amp;nbsp;Expected&amp;nbsp;value&amp;nbsp;is&amp;nbsp;0x68.&lt;/p&gt;
&lt;p&gt;The value 0x68 is 104 (decimal), maybe this is not an error code.&amp;nbsp;&lt;br /&gt;A logic analyzer trace is very useful.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usıng TWI with BLE nRF52dk</title><link>https://devzone.nordicsemi.com/thread/304779?ContentTypeID=1</link><pubDate>Wed, 14 Apr 2021 11:13:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3813189a-5835-4b4a-adff-f7582a6510d7</guid><dc:creator>kefom</dc:creator><description>&lt;p&gt;i did added debug to my definitions and got&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;error&amp;gt; app: ERROR 104 [Unknown error code] at C:\Users\HP\Desktop\nrf_sdk_17\nRF5_SDK_17.0.0_9d13099\examples\MY PROJECT\ble_app_Fall\Lib\mpu6050.c:29
PC at: 0x0002FF7D
&amp;lt;error&amp;gt; app: End of error report&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usıng TWI with BLE nRF52dk</title><link>https://devzone.nordicsemi.com/thread/304676?ContentTypeID=1</link><pubDate>Tue, 13 Apr 2021 20:25:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2549d8e-fb34-4529-a2a9-ad2d8d0948c5</guid><dc:creator>kefom</dc:creator><description>&lt;p&gt;i tried debugging it but i cant see any error code its always 0x00 in the times that i can see but when it enters nrf libraries it just goes to nrf_breakpoint and i cant put a red dot ( break point) so i cant look whats going on&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i can explain like this :&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int main(void)
{
    bool erase_bonds;
    // Initialize.
    log_init();
    timers_init();
    buttons_leds_init(&amp;amp;erase_bonds);
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
    peer_manager_init();

    // Start execution.
    NRF_LOG_INFO(&amp;quot;setting done&amp;quot;);
    application_timers_start();
    NRF_LOG_INFO(&amp;quot;timers started&amp;quot;);
    advertising_start(erase_bonds);

    I2C_init();
    NRF_LOG_INFO(&amp;quot;I2C is done&amp;quot;);
    mpu6050_init();
    NRF_LOG_INFO(&amp;quot;mpu6050 is done&amp;quot;);

    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;it starts in main then enters&lt;pre class="ui-code" data-mode="text"&gt;    mpu6050_init();&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;bool mpu6050_init(void)
{   
  bool transfer_succeeded = true;
	
  //Check the id to confirm that we are communicating with the right device
  transfer_succeeded &amp;amp;= mpu6050_verify_product_id();
	
  if(mpu6050_verify_product_id() == false)
    {
	return false;
      }

  // Set the registers with the required values, see the datasheet to get a good idea of these values
  (void)writeByte(MPU6050_ADDRESS, MPU_PWR_MGMT1_REG , 0x00); 
  (void)writeByte(MPU6050_ADDRESS, MPU_SAMPLE_RATE_REG , 0x07); 
  (void)writeByte(MPU6050_ADDRESS, MPU_CFG_REG , 0x06); 						
  (void)writeByte(MPU6050_ADDRESS, MPU_INT_EN_REG, 0x00); 
  (void)writeByte(MPU6050_ADDRESS, MPU_GYRO_CFG_REG , 0x18); 
  (void)writeByte(MPU6050_ADDRESS, MPU_ACCEL_CFG_REG,0x00);   		

  return transfer_succeeded;
}
&lt;/pre&gt;from here it enters&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;  transfer_succeeded &amp;amp;= mpu6050_verify_product_id();
  
  // which is
  
  
  bool mpu6050_verify_product_id(void)
{
    uint8_t who_am_i; // create a variable to hold the who am i value
    ret_code_t err_code;
    
    // Note: All the register addresses including WHO_AM_I are declared in 
    // MPU6050.h file, you can check these addresses and values from the
    // datasheet of your slave device.
    err_code=readByte(MPU6050_ADDRESS, ADDRESS_WHO_AM_I);
    APP_ERROR_CHECK(err_code);

    who_am_i= readByte(MPU6050_ADDRESS, ADDRESS_WHO_AM_I);

        if (who_am_i != MPU6050_WHO_AM_I)
        {
            return false;
        }
        else
        {
            return true;
        }

}&lt;/pre&gt;in this function it goes to&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    who_am_i= readByte(MPU6050_ADDRESS, ADDRESS_WHO_AM_I);
    
    
    

uint8_t readByte(uint8_t address, uint8_t subAddress)
{
    ret_code_t err_code = 0;
    
    uint8_t value;
    
    m_xfer_done = false;
 
    err_code = nrf_drv_twi_tx(&amp;amp;i2c, address, &amp;amp;subAddress, 1, true);

    APP_ERROR_CHECK(err_code);
    
    while (m_xfer_done == false); //wait until end of transfer
    
    if (err_code == NRF_SUCCESS)
    {
        m_xfer_done = false;
       
        err_code = nrf_drv_twi_rx(&amp;amp;i2c, address, &amp;amp;value, 1);
        APP_ERROR_CHECK(err_code);
        
        while (m_xfer_done == false);
    };

    return value;
}&lt;/pre&gt;from here&lt;pre class="ui-code" data-mode="text"&gt;    err_code = nrf_drv_twi_tx(&amp;amp;i2c, address, &amp;amp;subAddress, 1, true);


// here the err_code is 0x00


ret_code_t nrf_drv_twi_tx(nrf_drv_twi_t const * p_instance,
                          uint8_t               address,
                          uint8_t const *       p_data,
                          uint8_t               length,
                          bool                  no_stop)
{
    ret_code_t result = 0;
    if (NRF_DRV_TWI_USE_TWIM)
    {
        result = nrfx_twim_tx(&amp;amp;p_instance-&amp;gt;u.twim,
                                address, p_data, length, no_stop);
    }
    else if (NRF_DRV_TWI_USE_TWI)
    {
        result = nrfx_twi_tx(&amp;amp;p_instance-&amp;gt;u.twi,
                               address, p_data, length, no_stop);
    }
    return result;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrfx_err_t nrfx_twim_tx(nrfx_twim_t const * p_instance,
                        uint8_t             address,
                        uint8_t     const * p_data,
                        size_t              length,
                        bool                no_stop)
{
    nrfx_twim_xfer_desc_t xfer = NRFX_TWIM_XFER_DESC_TX(address, (uint8_t*)p_data, length);

    return nrfx_twim_xfer(p_instance, &amp;amp;xfer, no_stop ? NRFX_TWIM_FLAG_TX_NO_STOP : 0);
}

// from this line 

 nrfx_twim_xfer_desc_t xfer = NRFX_TWIM_XFER_DESC_TX(address, (uint8_t*)p_data, length);
 
 // i cant follow the code and i dont want to change the code and risk it should i risk it and add err_code here ?&lt;/pre&gt;and after this it goes to nrf_breakpoint_cond or just enters a part in disassembly and stay there and does nothing&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i know i couldnt make myself clear enough sorry about that i am new in this line of work&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards and many thanks&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Efe&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usıng TWI with BLE nRF52dk</title><link>https://devzone.nordicsemi.com/thread/304464?ContentTypeID=1</link><pubDate>Tue, 13 Apr 2021 10:14:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9af52aff-ec84-44fd-9820-4d9db112b733</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;What is the error code returned from&amp;nbsp;nrfx_twim_tx() in this case?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usıng TWI with BLE nRF52dk</title><link>https://devzone.nordicsemi.com/thread/304380?ContentTypeID=1</link><pubDate>Mon, 12 Apr 2021 21:45:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dbadd92a-46ee-437f-b415-b7b26a792ae4</guid><dc:creator>kefom</dc:creator><description>&lt;p&gt;i tried debugging but unfortunately&amp;nbsp;i cant go furter from this code it breaks down from here and goes does nothing and sometimes it just goes to nrf_breakpoint and wants to reset itself i followed this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; nrfx_twim_xfer_desc_t xfer = NRFX_TWIM_XFER_DESC_TX(address, (uint8_t*)p_data, length);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;this function is normal sdk code and now i dont know how to fix this&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrfx_err_t nrfx_twim_tx(nrfx_twim_t const * p_instance,
                        uint8_t             address,
                        uint8_t     const * p_data,
                        size_t              length,
                        bool                no_stop)
{
    nrfx_twim_xfer_desc_t xfer = NRFX_TWIM_XFER_DESC_TX(address, (uint8_t*)p_data, length);

    return nrfx_twim_xfer(p_instance, &amp;amp;xfer, no_stop ? NRFX_TWIM_FLAG_TX_NO_STOP : 0);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usıng TWI with BLE nRF52dk</title><link>https://devzone.nordicsemi.com/thread/304248?ContentTypeID=1</link><pubDate>Mon, 12 Apr 2021 11:42:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39dec4ee-886f-4db7-914e-5a3aded3c44b</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;You might want to build with Debug instead of Release, then you may find if the code is asserting:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/an-introduction-to-error-handling-in-nrf5-projects"&gt;https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/an-introduction-to-error-handling-in-nrf5-projects&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then you can set a breakpoint in&amp;nbsp;&lt;code&gt;app_error_fault_handler()&amp;nbsp;&lt;/code&gt;to find the exact error code and file number and file name the error occurs.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>