<?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>BMI270 init problem nrf52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/105152/bmi270-init-problem-nrf52840</link><description>Hello everyone, 
 i&amp;#39;m having some issues on configurate the BMI270 sensor using nrf52840 dongle&amp;#39;s twi interface. The initialization process includes a burst writing of a configuration file of 8Kbytes dimension on a single register of the sensor, due to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 03 Nov 2023 07:20:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/105152/bmi270-init-problem-nrf52840" /><item><title>RE: BMI270 init problem nrf52840</title><link>https://devzone.nordicsemi.com/thread/453878?ContentTypeID=1</link><pubDate>Fri, 03 Nov 2023 07:20:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25090772-144c-4183-8d41-4cf8169bb4cf</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;BMI270_conf_file_init is called after&amp;nbsp; if(!BMI270_register_write(0x59,0x00)) and it looks like&amp;nbsp;you are continuing to write to the sensor even if the previous&amp;nbsp;nrf_drv_twi_tx returned with an error. Are you sure that all previous transactions succeeded and can you see that data on TWI SDA pin using ossiloscope or logic analyzer?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 init problem nrf52840</title><link>https://devzone.nordicsemi.com/thread/453481?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2023 11:44:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b5c04bd-ea66-484c-a68c-e6d24ed80cf1</guid><dc:creator>Shinicy99</dc:creator><description>&lt;p&gt;Sorry for the misunderstanding but i meant after the first iteration the log gives me that error. If you want i will attach the project anyway.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://polimi365-my.sharepoint.com/:f:/g/personal/10659965_polimi_it/Eh4pGyT_l5NDsaOBM6g_9VIB5R_LNKqo9fVkfmkB69nFVg?e=YJlpp9"&gt;017template_twi_dongle_init_BMI&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 init problem nrf52840</title><link>https://devzone.nordicsemi.com/thread/453434?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2023 08:27:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65cff202-09af-4630-9951-4e652a0cb483</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Getting a busy error code is pretty clear that you are calling nrf_drv_twi_tx before the previous transaction is complete. You said that this is the first iteration in which you NRF_ERROR_BUSY error, that should not be possible. Are you sure you are not calling twi_tx function in any context. Can you please attach your project here so that I can test it myself?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 init problem nrf52840</title><link>https://devzone.nordicsemi.com/thread/453341?ContentTypeID=1</link><pubDate>Tue, 31 Oct 2023 15:33:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18eacb29-eb1d-49ff-a079-8bf7174bbddf</guid><dc:creator>Shinicy99</dc:creator><description>&lt;p&gt;i tried to run the code on a pca10040 to use it as a debugger, i had to remove all the code related to usbd communication(so i&amp;#39;m not able to understand if there is any conflict with that part).&lt;/p&gt;
&lt;p&gt;i modified the code for multiple writing in this way:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int BMI270_conf_file_init(void)
{
   uint8_t buff[2];
   int a;
   ret_code_t err_code;


   for(a=0;a&amp;lt;sizeof(bmi270_context_config_file);a++)
   {
     buff[0]=0x5E;
     buff[1]=bmi270_context_config_file[a];
     err_code=nrf_drv_twi_tx(&amp;amp;m_twi,BMI2_I2C_PRIM_ADDR,buff,2,false);
    while(m_xfer_done==false){}
    APP_ERROR_CHECK(err_code);
    if(err_code != NRF_SUCCESS)
        {
            return a;
        }
  
           
   }
   
   return a;
    
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and logging with putty the log gives me this error&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app: Application Started &amp;lt;----- this is the device&amp;#39;s start string
&amp;lt;error&amp;gt; app: ERROR 17 [NRF_ERROR_BUSY] at D:\UniD\(D)A.A. 2022-2023\TESI\sviluppo dispositivo\nrf_sdk\examples\My Projects\018 debugging init bmi270\BMI270_custom\BMI270_custom.c:688
PC at: 0x0000BFCB
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;also by omitting the APP_ERROR_CHECK code and running the debug, watching the err_code if i step once at a time it gives no error but if i run the debug inside the function it stops at first iteration by returning an&amp;nbsp;0x00000011. during while loop.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 init problem nrf52840</title><link>https://devzone.nordicsemi.com/thread/453071?ContentTypeID=1</link><pubDate>Mon, 30 Oct 2023 14:14:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81cdcfd4-f58a-49e6-b955-18a40fa9bdb4</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Like I said, run the code in debugger and halt the debugger after a while and see which context you are running in. If you are stuck in some context, that is very good info to start with.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 init problem nrf52840</title><link>https://devzone.nordicsemi.com/thread/453056?ContentTypeID=1</link><pubDate>Mon, 30 Oct 2023 13:40:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f15acbd5-9380-4c90-93aa-10f122f08dcc</guid><dc:creator>Shinicy99</dc:creator><description>&lt;p&gt;the function conf_file_init is called in the bmi270_init code that is called in the main before while loop, this is the init function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;//init function of bmi270
int BMI270_init(void)
{
  
  bool init_succ=true;
  
  //following datasheet  
  if(!BMI270_verify_product_id())
  {
   init_succ=false;
  }
  
  if(!BMI270_register_write(0x7C,0x00))
  {
    init_succ=false;
  }

  nrf_delay_us(800);

  if(!BMI270_register_write(0x59,0x00))
  {
    init_succ=false;
  }

  /*
  if(!BMI270_conf_file_init())
  {
    init_succ=false;
  }
  */

  int a;
  a=BMI270_conf_file_init();

 if(!BMI270_register_write(0x59,0x01)){
    init_succ=false;//not good
  }

  return a;

}

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;that is called at lines 32 of main function in the first section of this post&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;PS: this is the declaration fo twi init:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void twi_master_init(void)
{

  ret_code_t err_code;
  
  //configure settings
  const nrf_drv_twi_config_t twi_config={
      .scl                          =NRF_GPIO_PIN_MAP(1,0),//SET PIN SCL
      .sda                          =NRF_GPIO_PIN_MAP(0,24),//SET PIN SDA
      .frequency                    =NRF_DRV_TWI_FREQ_100K,//SET F
      .interrupt_priority           =APP_IRQ_PRIORITY_HIGH,//PRIORITY PAY ATTENTION WHEN USE BT
      .clear_bus_init               =false
};

  err_code=nrf_drv_twi_init(&amp;amp;m_twi,&amp;amp;twi_config,twi_handl,NULL);
  APP_ERROR_CHECK(err_code);
  //enable twi comunication
  nrf_drv_twi_enable(&amp;amp;m_twi);

}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 init problem nrf52840</title><link>https://devzone.nordicsemi.com/thread/453034?ContentTypeID=1</link><pubDate>Mon, 30 Oct 2023 12:40:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fed9931-1ad1-4598-9553-5c9fa13162b5</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Is the event handler running atleast once? Can you add the log there to see?&lt;/p&gt;
&lt;p&gt;Are you running the&amp;nbsp;BMI270_conf_file_init in the main() function or is it running in some other interrupt context? I see that you have while(m_xfer_done == false) in the init function which will only work if you have this init function in the lower priority than the event handler (TWI interrupt priority)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 init problem nrf52840</title><link>https://devzone.nordicsemi.com/thread/453018?ContentTypeID=1</link><pubDate>Mon, 30 Oct 2023 12:10:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47c6b39e-2a4b-40c6-b722-40aa91119adb</guid><dc:creator>Shinicy99</dc:creator><description>&lt;p&gt;hello, this is the code of the evnt handler:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;//twi event handler
void twi_handl(nrf_drv_twi_evt_t const *p_event,void *p_context)
{
  switch(p_event-&amp;gt;type)
  {
  
    case NRF_DRV_TWI_EVT_DONE:
    m_xfer_done=true;// set the flag
    break;

    default:
    //nothing
      break; 
  }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;by the way, can you suggest (if there is any way) to simulate debuggin from Segger Embedded Studio? Beacuase as i&amp;#39;m using dongle a debbugger is not included so i have to transfer the code on a DK that i don&amp;#39;t have right away. Thanks for your support.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 init problem nrf52840</title><link>https://devzone.nordicsemi.com/thread/453009?ContentTypeID=1</link><pubDate>Mon, 30 Oct 2023 11:48:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e53edf3-7395-4c89-80d5-a9924fe6179a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Can you start you application in the debugger and test the same thing again and after you run for a while, pause the debugger (pause but do not stop) You will then know the context of the execution. It seems like it is stuck in the while loop or somewhere else (deadlock). I also do not see if there is any twi_handler that you initialized in the&amp;nbsp;nrf_drv_twi_init?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 init problem nrf52840</title><link>https://devzone.nordicsemi.com/thread/452981?ContentTypeID=1</link><pubDate>Mon, 30 Oct 2023 10:09:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9d44ebc-0edc-4dce-8862-04020eb6fdd3</guid><dc:creator>Shinicy99</dc:creator><description>&lt;p&gt;UPDATE:&lt;/p&gt;
&lt;p&gt;I tried to modify the burst writing function and trying to understand if there is a problem on the for loop and i tried to return the values of the cycle counter.&lt;/p&gt;
&lt;p&gt;Here is the code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int BMI270_conf_file_init(void)
{
   uint8_t buff[2];
   int a;
   ret_code_t err_code;


   for(a=0;a&amp;lt;sizeof(bmi270_context_config_file);a++)
   {
     buff[0]=0x5E;
     buff[1]=bmi270_context_config_file[a];
     err_code=nrf_drv_twi_tx(&amp;amp;m_twi,BMI2_I2C_PRIM_ADDR,buff,2,false);
     while(m_xfer_done==false){}
    
    if(err_code != NRF_SUCCESS)
        {
            return 0;
        }
  
           
   }
   return a;
    
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and this is the part of the main code modified for reading this step count:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int count_info;
    count_info=BMI270_init();    
    NRF_LOG_INFO(&amp;quot;LSM6DSO init success!!&amp;quot;);
    NRF_LOG_INFO(&amp;quot;Reading values:....&amp;quot;);
    
    BMI270_default();


    NRF_LOG_FLUSH();
    
    int16_t gyro[3],acc[3];

    while (true)
    {
        while (app_usbd_event_queue_process())
        {
            /* Nothing to do */
        }
        

        if(!flag_notinit &amp;amp;&amp;amp; m_send_flag)
        {
          size_t size = sprintf(m_tx_buffer, &amp;quot;INITIALIZATION PROBLEM\r\nCount info: %d&amp;quot;);
        ret = app_usbd_cdc_acm_write(&amp;amp;m_app_cdc_acm, m_tx_buffer, size);
        nrf_delay_ms(500);
        }else{
        

        uint8_t register_read;
        if(flag_register_reading_info &amp;amp;&amp;amp; m_send_flag)
        {
          BMI270_register_read(0x5E,&amp;amp;register_read,1);
          size_t size = sprintf(m_tx_buffer, &amp;quot;byte REGISTER:     %d\r\n\n count info: %d&amp;quot;,register_read,count_info);
          ret = app_usbd_cdc_acm_write(&amp;amp;m_app_cdc_acm, m_tx_buffer, size);
           nrf_delay_ms(1000);
         }
      }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;it seems that there is a problem on the for loop if my code is right, as the return string in the serial monitor reveals this:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/read-step.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>