<?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>nRF 52 TWI in LSM9DS1</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46574/nrf-52-twi-in-lsm9ds1</link><description>Hello, 
 I want to test the IKS01A1 (STM) board with the STEVAL-MKI159v1 board by placing the IKS board in the Arduino connectors on the nRF52 (PCA10056) DK board. 
 I want to use this driver: 
 https://github.com/STMicroelectronics/STMems_Standard_C_drivers</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 07 May 2019 12:44:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46574/nrf-52-twi-in-lsm9ds1" /><item><title>RE: nRF 52 TWI in LSM9DS1</title><link>https://devzone.nordicsemi.com/thread/185735?ContentTypeID=1</link><pubDate>Tue, 07 May 2019 12:44:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:233366f9-5969-4875-aa94-8d888f9f5922</guid><dc:creator>drVrh</dc:creator><description>&lt;p&gt;&lt;span&gt;I solved the problems, as you can see in in the attached code.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://github.com/drvrh/nRF52-DK-and-LSM9DS1"&gt;github.com/.../nRF52-DK-and-LSM9DS1&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;For further work we need to include the header file from: &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/master/lsm9ds1_STdC/driver"&gt;github.com/.../driver&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;the attached example comed from this source:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/master/lsm9ds1_STdC/example"&gt;https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/master/lsm9ds1_STdC/example&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;Note for Segger studio:&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div class="_1t_p clearfix"&gt;
&lt;div class="_41ud"&gt;
&lt;div class="clearfix _o46 _3erg _3i_m _nd_ direction_ltr text_align_ltr"&gt;
&lt;div class="_3058 _ui9 _hh7 _6ybn _s1- _52mr _43by _3oh-" id="js_jit"&gt;
&lt;div class="_aok"&gt;&lt;em&gt;&lt;span class="_3oh- _58nk"&gt;printf should be enabled in: right mouse click on project &amp;gt; Options &amp;gt; choose Common &amp;gt; in search box type &amp;quot;float&amp;quot; &amp;gt; change Printf Floating Point Supported from No to float.&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div class="_1t_p clearfix"&gt;
&lt;div class="_1t_q"&gt;
&lt;div class="_7934 _150g uiPopover _6a _6b"&gt;
&lt;div class="_4ldz _1t_r _p" id="js_jdu"&gt;
&lt;div class="_4ld-"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="_41ud"&gt;
&lt;h5 class="_ih3 _-ne"&gt;&lt;/h5&gt;
&lt;div class="clearfix _o46 _3erg _29_7 direction_ltr text_align_ltr"&gt;
&lt;div class="_3058 _ui9 _hh7 _6ybn _s1- _52mr _3oh-" id="js_js0"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF 52 TWI in LSM9DS1</title><link>https://devzone.nordicsemi.com/thread/184553?ContentTypeID=1</link><pubDate>Tue, 30 Apr 2019 12:08:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c56a849c-2ce4-4e0f-8cb2-ca130df12e80</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you looked at our SDK example: nRF5_SDK_15.3.0_59ac345\examples\peripheral\twi_master_with_twis_slave?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF 52 TWI in LSM9DS1</title><link>https://devzone.nordicsemi.com/thread/183634?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 06:26:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b158f80-1079-4b61-9332-6eb7fac5367a</guid><dc:creator>drVrh</dc:creator><description>&lt;p&gt;&lt;span&gt;I modified the functions platform_read and platform_write from read_data_simple.c (from github) like this: &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static int32_t platform_write(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len){

    uint8_t *i2c_address = handle;

    ret_code_t err_code = nrf_drv_twi_tx(&amp;amp;m_twi, *i2c_address, &amp;amp;reg, len, false);
    APP_ERROR_CHECK(err_code);
    while (m_xfer_done == false);

    m_xfer_done = false;
    /* Read 1 byte from the specified address - skip 3 bits dedicated for fractional part of temperature. */
    err_code = nrf_drv_twi_rx(&amp;amp;m_twi, *i2c_address, bufp, len);
    APP_ERROR_CHECK(err_code);

  return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len){
  uint8_t *i2c_address = handle;

    m_xfer_done = false;

    /* Read 1 byte from the specified address - skip 3 bits dedicated for fractional part of temperature. */
    ret_code_t err_code = nrf_drv_twi_rx(&amp;amp;m_twi, *i2c_address, &amp;amp;reg, len);
    APP_ERROR_CHECK(err_code);

    m_xfer_done = false;

    /* Read 1 byte from the specified address - skip 3 bits dedicated for fractional part of temperature. */
    err_code = nrf_drv_twi_rx(&amp;amp;m_twi, *i2c_address, bufp, len);
    APP_ERROR_CHECK(err_code);

  return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;my TWI init is:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void twi_init (void)
{
    ret_code_t err_code;

    const nrf_drv_twi_config_t twi_lm75b_config = {
       .scl                = ARDUINO_SCL_PIN,
       .sda                = ARDUINO_SDA_PIN,
       .frequency          = NRF_DRV_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

    err_code = nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_lm75b_config, NULL, NULL);
    APP_ERROR_CHECK(err_code);

    nrf_drv_twi_enable(&amp;amp;m_twi);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;in my main is the&amp;nbsp;first lines is:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO(&amp;quot;\r\nTWI mems example started.&amp;quot;);
    NRF_LOG_FLUSH();
    twi_init();

/* Initialize inertial sensors (IMU) driver interface */
  uint8_t i2c_add_mag = LSM9DS1_MAG_I2C_ADD_L;
  lsm9ds1_ctx_t dev_ctx_mag;
  dev_ctx_mag.write_reg = platform_write;
  dev_ctx_mag.read_reg = platform_read;
  dev_ctx_mag.handle = (void*)&amp;amp;i2c_add_mag;

  /* Initialize magnetic sensors driver interface */
  uint8_t i2c_add_imu = LSM9DS1_IMU_I2C_ADD_H;
  lsm9ds1_ctx_t dev_ctx_imu;
  dev_ctx_imu.write_reg = platform_write;
  dev_ctx_imu.read_reg = platform_read;
  dev_ctx_imu.handle = (void*)&amp;amp;i2c_add_imu;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;other main function is equal like read_data_simple.c&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;my problem: is that I get NRF_BREAKPOINT_COND on 100th line from app_error_weak.c with NRF_LOG this message: &amp;lt;error&amp;gt; app: Fatal error&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>