<?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>Custom NRF52832 + LIS2DH12 accelerometer but always get &amp;#39;0&amp;#39;</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66238/custom-nrf52832-lis2dh12-accelerometer-but-always-get-0</link><description>I got a nrf52832 custom board to communicate with LIS2DH12 accelerometer by I2C(TWI). 
 I edited part of the code from &amp;quot;twi_sensor&amp;quot; project in NRF5_SDK version 17.0. 
 I tried to read the &amp;quot;x_out_low &amp;quot; byte from LIS2DH12, but always get zero. 
 
 Here</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Feb 2021 15:52:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66238/custom-nrf52832-lis2dh12-accelerometer-but-always-get-0" /><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/296616?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 15:52:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:123a7a4e-0590-4c4c-9487-c5995c26a3eb</guid><dc:creator>kbk</dc:creator><description>&lt;p&gt;Thanks I&amp;#39;m using segger studio as well. Wish segger had a share project to archive feature...&lt;/p&gt;
&lt;p&gt;Kevin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/296615?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 15:49:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed1dc26f-6fda-4002-bed0-a08128e5778a</guid><dc:creator>Leo Yang</dc:creator><description>&lt;p&gt;Hi, kbk&lt;/p&gt;
&lt;p&gt;I use SEGGER studio to program, right-click the variable =&amp;gt; Go To Definition.&lt;/p&gt;
&lt;p&gt;It will be much more easier to trace code. : &amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1614353831283v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the functions I use:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void read_all_cb(ret_code_t result, void *p_user_data) {
    if (result != NRF_SUCCESS) {
        NRF_LOG_WARNING(&amp;quot;read_all_cb - error: %d&amp;quot;, (int)result);
        return;
    }
    if (DEBUG)
        NRF_LOG_RAW_INFO(&amp;quot;Reading......\n&amp;quot;);

    float x_gscale_val, y_gscale_val, z_gscale_val;

    x_gscale_val = (float)((int16_t)((((uint16_t)m_buffer[1]) &amp;lt;&amp;lt; 8) | m_buffer[0])) / (16 * 1024) + 0.43;
    y_gscale_val = (float)((int16_t)((((uint16_t)m_buffer[3]) &amp;lt;&amp;lt; 8) | m_buffer[2])) / (16 * 1024) + 0.4;
    z_gscale_val = (float)((int16_t)((((uint16_t)m_buffer[5]) &amp;lt;&amp;lt; 8) | m_buffer[4])) / (16 * 1024) - 0.2;

    if (timer_counter &amp;lt; RECORDING_MAX_TIME_STEP) {
        NRF_LOG_RAW_INFO(&amp;quot;%d: &amp;quot;, timer_counter);
        NRF_LOG_RAW_INFO(NRF_LOG_FLOAT_MARKER &amp;quot;, &amp;quot;, NRF_LOG_FLOAT(x_gscale_val));
        NRF_LOG_RAW_INFO(NRF_LOG_FLOAT_MARKER &amp;quot;, &amp;quot;, NRF_LOG_FLOAT(y_gscale_val));
        NRF_LOG_RAW_INFO(NRF_LOG_FLOAT_MARKER &amp;quot;\n&amp;quot;, NRF_LOG_FLOAT(z_gscale_val));
    }
    if(timer_counter != RECORDING_MAX_TIME_STEP){
        z_raw_val[timer_counter] = z_gscale_val;
        timer_counter += 1;
    }
}
static void read_all(void) {
    // [these structures have to be &amp;quot;static&amp;quot; - they cannot be placed on stack
    //  since the transaction is scheduled and these structures most likely
    //  will be referred after this function returns]
    static nrf_twi_mngr_transfer_t const transfers[] =
#ifdef LIS2DH12
        {LIS2DH12_READ_XYZ(&amp;amp;m_buffer[0])};
#else
        {ADXL345_READ_XYZ(&amp;amp;m_buffer[0])};
#endif
    static nrf_twi_mngr_transaction_t NRF_TWI_MNGR_BUFFER_LOC_IND transaction =
        {
            .callback = read_all_cb,
            .p_user_data = NULL,
            .p_transfers = transfers,
            .number_of_transfers = sizeof(transfers) / sizeof(transfers[0])};

    APP_ERROR_CHECK(nrf_twi_mngr_schedule(&amp;amp;m_nrf_twi_mngr, &amp;amp;transaction));

    // Signal on LED that something is going on.
    // bsp_board_led_invert(READ_ALL_INDICATOR);

    if (DEBUG)
        NRF_LOG_RAW_INFO(&amp;quot;Read end\n\n&amp;quot;);
}

static void bsp_config(void) {
    uint32_t err_code;

    err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);

    APP_ERROR_CHECK(err_code);
}

// TWI (with transaction manager) initialization.
static void twi_config(void) {
    uint32_t err_code;

    nrf_drv_twi_config_t const config = {
        .scl = SCL_PIN,
        .sda = SDA_PIN,
        .frequency = NRF_DRV_TWI_FREQ_100K,
        .interrupt_priority = APP_IRQ_PRIORITY_LOWEST,
        .clear_bus_init = false};

    err_code = nrf_twi_mngr_init(&amp;amp;m_nrf_twi_mngr, &amp;amp;config);
    APP_ERROR_CHECK(err_code);
}

static void lfclk_config(void) {
    uint32_t err_code;

    err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK(err_code);

    nrf_drv_clock_lfclk_request(NULL);
}

void timer_handler(void *p_context) {
    read_all();
}

void read_init(void) {
    ret_code_t err_code;

    err_code = app_timer_create(&amp;amp;m_timer, APP_TIMER_MODE_REPEATED, timer_handler);
    APP_ERROR_CHECK(err_code);

    err_code = app_timer_start(m_timer, APP_TIMER_TICKS(20), NULL);
    APP_ERROR_CHECK(err_code);
}

void log_init(void) {
    ret_code_t err_code;

    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
}

void power_init(void) {
    ret_code_t err_code;

    err_code = nrf_pwr_mgmt_init();
    APP_ERROR_CHECK(err_code);
}

void gpio_config(void) {
    nrf_gpio_cfg_output(4);
    nrf_gpio_pin_set(8);
    nrf_delay_ms(30);

    nrf_gpio_cfg_output(4);
    nrf_gpio_pin_set(4);
    nrf_gpio_cfg_output(LED_1);
}

void setup(void) {
    log_init();
    // bsp = Board Support Package
    bsp_board_init(BSP_INIT_LEDS);

    // Start internal LFCLK XTAL oscillator - it is needed by BSP to handle
    // buttons with the use of APP_TIMER and for &amp;quot;read_all&amp;quot; ticks generation
    // (by RTC).
    lfclk_config();
    bsp_config();
    power_init();
    gpio_config();
    // Wait for LIS2D12 Turn-on time
    nrf_delay_ms(300);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Not all the functions in lis2dh12.h are used, I use LIS2DH12_READ_XYZ only.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;div style="left:-19px;position:absolute;top:731.133px;" id="gtx-trans"&gt;
&lt;div class="gtx-trans-icon"&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/296601?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 14:59:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:713771e2-a9ce-4b49-85ce-b0f14040ff2e</guid><dc:creator>kbk</dc:creator><description>&lt;p&gt;Hello Leo&lt;/p&gt;
&lt;p&gt;Thank you very much for taking the time to post this for me. I understand adding the two lis2dh12.files and I assume what you have here in the main.c code above is what I add to the main.c for the &amp;quot;twi_master_using_nrf_twi_mngr&amp;quot; project. Is that correct so far? What I don&amp;#39;t understand is what is it that will call anything in those two added files... (I&amp;#39;m a terrible programmer) if you can help me further it would be very much appreciated.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Kevin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/296409?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 02:32:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9488a7fd-3c44-4913-a043-5f6dce058c11</guid><dc:creator>Leo Yang</dc:creator><description>&lt;p&gt;Hi, kbk. I basically use &amp;quot;twi_master_using_nrf_twi_mngr&amp;quot; project, and only edit some registers and values in &amp;quot;mma7660.h&amp;quot; and&amp;nbsp;&lt;span&gt;&amp;quot;mma7660.c&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt; to init lis2dh12. I called these file &amp;quot;lis2dh12.h&amp;quot; and &amp;quot;lis2dh12.c&amp;quot;.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the code:&lt;/p&gt;
&lt;p&gt;lis2dh12.h&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
#ifndef LIS2DH12_H_
#define LIS2DH12_H_

#include &amp;quot;nrf_twi_mngr.h&amp;quot;

#ifdef __cplusplus
extern &amp;quot;C&amp;quot; {
#endif

#define SCL_PIN 5
#define SDA_PIN 2

/** I2C Device Address 8 bit format if SA0=0 -&amp;gt; 31 if SA0=1 -&amp;gt; 33 **/
#define LIS2DH12_ADDR 0x19U
#define LIS2DH12_I2C_ADD_L 0x31U
#define LIS2DH12_I2C_ADD_H 0x33U

#define LIS2DH12_OUT_X_L 0x28U
#define LIS2DH12_OUT_X_H 0x29U
#define LIS2DH12_OUT_Y_L 0x2AU
#define LIS2DH12_OUT_Y_H 0x2BU
#define LIS2DH12_OUT_Z_L 0x2CU
#define LIS2DH12_OUT_Z_H 0x2DU
#define LIS2DH12_FIFO_CTRL_REG 0x2EU

#define LIS2DH12_NUMBER_OF_REGISTERS 11

// The Alert bit (6) set signals that the register must be read again, since
// its value may be inaccurate (it was read at the same time as the device was
// attempting to update it).
// Applies to XOUT, YOUT, ZOUT registers.
#define LIS2DH12_DATA_IS_VALID(reg_data) (!((reg_data) &amp;amp; (1U &amp;lt;&amp;lt; 6)))

// Gets acceleration (g) value (6-bit 2&amp;#39;s complement) from register data.
// [use &amp;quot;/ 4&amp;quot; instead of &amp;quot;&amp;gt;&amp;gt; 2&amp;quot;, as the result of right-shifting of a signed
//  type value is implementation-defined]
#define LIS2DH12_GET_ACC(reg_data) ((int8_t)((reg_data) &amp;lt;&amp;lt; 2) / 4)

// Get orientation of the device (PoLa bits from the Tilt Status register).
#define LIS2DH12_GET_ORIENTATION(tilt_status) (tilt_status &amp;amp; 0x1C)
#define LIS2DH12_ORIENTATION_LEFT 0x04
#define LIS2DH12_ORIENTATION_RIGHT 0x08
#define LIS2DH12_ORIENTATION_DOWN 0x14
#define LIS2DH12_ORIENTATION_UP 0x18

#define LIS2DH12_TAP_DETECTED(tilt_status) (tilt_status &amp;amp; (1U &amp;lt;&amp;lt; 5))
#define LIS2DH12_SHAKE_DETECTED(tilt_status) (tilt_status &amp;amp; (1U &amp;lt;&amp;lt; 7))

extern uint8_t NRF_TWI_MNGR_BUFFER_LOC_IND lis2dh12_xout_reg_addr;

#define LIS2DH12_READ(p_reg_addr, p_buffer, byte_cnt)                       \
    NRF_TWI_MNGR_WRITE(LIS2DH12_ADDR, p_reg_addr, 1, NRF_TWI_MNGR_NO_STOP), \
        NRF_TWI_MNGR_READ(LIS2DH12_ADDR, p_buffer, byte_cnt, 0)

#define LIS2DH12_READ_XYZ(p_buffer) \
    LIS2DH12_READ(&amp;amp;lis2dh12_xout_reg_addr, p_buffer, 6)

#define LIS2DH12_INIT_TRANSFER_COUNT 4

extern nrf_twi_mngr_transfer_t const
    lis2dh12_init_transfers[LIS2DH12_INIT_TRANSFER_COUNT];

#ifdef __cplusplus
}
#endif

#endif // LIS2DH12_H_&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;lis2dh12.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
/** @file
 * @defgroup nrf_twi_master_example main.c
 * @{
 * @ingroup nrf_twi_example
 * @brief TWI Example Application main file.
 *
 * This file contains the source code for a sample application using TWI.
 *
 * @image html example_board_setup_a.jpg &amp;quot;Use board setup A for this example.&amp;quot;
 */


#include &amp;quot;lis2dh12.h&amp;quot;

uint8_t NRF_TWI_MNGR_BUFFER_LOC_IND lis2dh12_xout_reg_addr = (LIS2DH12_OUT_X_L | 0x80);

static uint8_t NRF_TWI_MNGR_BUFFER_LOC_IND CTRL_REG1[] = { 0x20, 0x57 };
// set data rate to 100 Hz

static uint8_t NRF_TWI_MNGR_BUFFER_LOC_IND CTRL_REG4[] = { 0x23, 0x04 };
// set full-scale to +/- 2g

static uint8_t NRF_TWI_MNGR_BUFFER_LOC_IND CTRL_REG5[] = { 0x24, 0x40 };
// set FIFO enable bit

static uint8_t NRF_TWI_MNGR_BUFFER_LOC_IND FIFO_CTRL[] = { 0x2E, 0x80 };
// set FIFO to stream mode

nrf_twi_mngr_transfer_t const lis2dh12_init_transfers[LIS2DH12_INIT_TRANSFER_COUNT] =
{
    NRF_TWI_MNGR_WRITE(LIS2DH12_ADDR, CTRL_REG1, sizeof(CTRL_REG1), 0),
    NRF_TWI_MNGR_WRITE(LIS2DH12_ADDR, CTRL_REG4, sizeof(CTRL_REG4), 0),
    NRF_TWI_MNGR_WRITE(LIS2DH12_ADDR, CTRL_REG5, sizeof(CTRL_REG5), 0),
    NRF_TWI_MNGR_WRITE(LIS2DH12_ADDR, FIFO_CTRL, sizeof(FIFO_CTRL), 0)
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and main.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void setup(void) {
    log_init();
    // bsp = Board Support Package
    bsp_board_init(BSP_INIT_LEDS);

    // Start internal LFCLK XTAL oscillator - it is needed by BSP to handle
    // buttons with the use of APP_TIMER and for &amp;quot;read_all&amp;quot; ticks generation
    // (by RTC).
    lfclk_config();
    bsp_config();
    power_init();
    gpio_config();
    // Wait for LIS2D12 Turn-on time
    nrf_delay_ms(300);
}

int main(void) {
    setup();

    twi_config();
    read_init();
    
    // Initialize sensor (lis2dh12 only).
    APP_ERROR_CHECK(nrf_twi_mngr_perform(&amp;amp;m_nrf_twi_mngr, NULL, lis2dh12_init_transfers,
        LIS2DH12_INIT_TRANSFER_COUNT, NULL));

    ......
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/296344?ContentTypeID=1</link><pubDate>Thu, 25 Feb 2021 15:40:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28b00556-064a-45aa-bc75-ae230c03ea8a</guid><dc:creator>kbk</dc:creator><description>&lt;p&gt;Hello Leo. Can you please share your code for the lis2hh12 and your nrf52 please?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/272133?ContentTypeID=1</link><pubDate>Tue, 29 Sep 2020 16:53:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8fe862f-556f-4b6c-8162-125975e02a58</guid><dc:creator>Leo Yang</dc:creator><description>&lt;p&gt;Finally, I figured it out. I forgot to set the FIFO enable bit in CTRL_REG5....&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1601398384741v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/271671?ContentTypeID=1</link><pubDate>Mon, 28 Sep 2020 07:32:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49eea4df-0900-4383-a03a-cf8b18679697</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;You need to scope the I/O lines and the sensor&amp;#39;s power supply...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/271385?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 15:28:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93d4e2f6-8557-42cb-af0e-e9440341eb5b</guid><dc:creator>Leo Yang</dc:creator><description>&lt;p&gt;I tried the code above, but still not working.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll keep trying. If I find something new, I &amp;#39;ll update the ticket.&lt;/p&gt;
&lt;p&gt;Thanks for your help, I really appreciate it. : )&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/271382?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 14:58:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af201150-7635-4d55-9408-ef5e1c66981f</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;High Drive &amp;#39;1&amp;#39; increases the current available from an i/o pin by turning on a second FET connecting the pin to Vdd internally in the nRF52. The LIS2DH12 doesn&amp;#39;t normally require high drive, but as I mentioned 10uF is too large for normal use on an i/o pin as the LIS2DH12 is a low-power part. Try this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt; //nrf_gpio_cfg_output(8);
 nrf_gpio_pin_set(8);
 nrf_gpio_cfg(8, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_S0H1, NRF_GPIO_PIN_NOSENSE);
 nrf_delay_ms(30);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Low drive with 10uF may cause too slow a power rise time for the LIS2DH12 to correctly start up&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/271375?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 14:28:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2dce566-1f53-485f-acf8-2a77f80e92f3</guid><dc:creator>Leo Yang</dc:creator><description>&lt;p&gt;Hi hmolesworth,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I reordered the gpio operation as you mentioned, but I still get &amp;#39;0&amp;#39; from X_OUT_L.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    nrf_gpio_cfg_output(8);
    nrf_gpio_pin_set(8);
    nrf_delay_ms(300);

    nrf_gpio_cfg_output(4);
    nrf_gpio_pin_set(4);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I tried to print all the value received from LIS2DH12 (X_OUT_L, X_OUT_H, Y_OUT_L, Y_OUT_H, Z_OUT_L, Z_OUT_H).&lt;/p&gt;
&lt;p&gt;However, I can only read either &amp;#39;0&amp;#39; or &amp;#39;255&amp;#39;.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the result:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1600955341673v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I also read the WHO_AM_I(0x0F) register, and I get a value(0x51) inconsistent with the value I shall get(0x33).&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1600955852533v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;==&amp;gt; &lt;strong&gt;I would suggest reducing to 1uF or less&lt;/strong&gt; but in any case set P0.08 to S0H1 drive.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Maybe to change the capacitor is not that easy, because I&amp;#39;m using a custom board which is just bigger than my thumb.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;==&amp;gt;&amp;nbsp;I would suggest reducing to 1uF or less&amp;nbsp;but in any case &lt;strong&gt;set P0.08 to S0H1 drive&lt;/strong&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nrf_gpio_cfg_output() function set the pin to&lt;strong&gt; S0S1&lt;/strong&gt;, will this be a problem?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What is the difference between &lt;strong&gt;Standard &amp;#39;0&amp;#39;, standard &amp;#39;1&amp;#39;&lt;/strong&gt; and&amp;nbsp;&lt;strong&gt;Standard &amp;#39;0&amp;#39;, high drive &amp;#39;1&amp;#39;&lt;/strong&gt;? &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Sorry, I&amp;#39;m really a newbie...&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1600956112921v7.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;regards&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/271189?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2020 18:57:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b20ece2-7bf1-466b-968d-5ef6d113de66</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Looks like&amp;nbsp; you do have the correct device address, I thought the TWI driver bit-shifted but I see now that it does not.&lt;/p&gt;
&lt;p&gt;The 10uF capacitor is very large for a standard nRF52 port pin to drive; I would suggest reducing to 1uF or less but in any case set P0.08 to S0H1 drive. P0.08 must be driven high &lt;em&gt;before&lt;/em&gt; P0.04 is driven high, as otherwise P0.04 provides phantom power via internal LIS2DH12 schottky clamp diode before real power is applied and that will cause the LIS2DH12 to behave badly. Allow a delay of (say) 30mSecs after raising P0.08 before setting P0.04 as an active high output to allow the huge 10uF capacitor to charge. This might correct the issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/271123?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2020 13:35:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42595afd-2194-4399-b521-b3fb217baff5</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;&amp;nbsp;You need to scope the I/O lines and the accelerometer&amp;#39;s power supply.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/271089?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2020 12:25:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e072f66-9e61-4d18-8ad8-672e77633364</guid><dc:creator>Leo Yang</dc:creator><description>&lt;p&gt;Thanks for your reply, haakonsh!&lt;/p&gt;
&lt;p&gt;Maybe the bit shift is kind of confusing. What I&amp;#39;m doing is to discard the LSB of the 8-bit address and make it&amp;nbsp;into a 7-bit address. The LSB in 0x33 is a R/W bit.&lt;/p&gt;
&lt;p&gt;0x33(0b 0011 001&lt;span style="text-decoration:underline;"&gt;&lt;em&gt;&lt;strong&gt;1&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;)&amp;nbsp; right shift&amp;nbsp; ==&amp;gt; 0x19(0b 0001 1001)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The i2c slave address table in datasheet,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1600861458023v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;Documentation:&amp;nbsp;&amp;nbsp;&lt;a href="https://www.mouser.tw/datasheet/2/389/dm00091513-1797743.pdf"&gt;https://www.mouser.tw/datasheet/2/389/dm00091513-1797743.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I read the input like this, and I know SA0 is connected to high, so the slave address will be 0x19(first 7 bit).&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    nrf_gpio_cfg_input(3, NRF_GPIO_PIN_PULLUP);
    int pin_status = nrf_gpio_pin_read(3);
    printf(&amp;quot;%d: %d\n&amp;quot;, 3, pin_status);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;guess my situation is more likely to be a hardware problem. I run the same code on NRF52DK + ADXL345, with only register and slave address change, it works fine. I can read non-zero value from ADXL345.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I pulled p0.04 high to enable I2C, and also pulled p0.08 high for power supply.&amp;nbsp;&amp;nbsp;Am I doing something wrong?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you, regards&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="left:157px;position:absolute;top:307.455px;" id="gtx-trans"&gt;
&lt;div class="gtx-trans-icon"&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/270987?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2020 07:54:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94d59ab2-131e-4efd-9fd3-0afc9f01b9b5</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;The driver will take care of the R/W bit. You need to decide whether to use address 0b11000 or 0b11001.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;By diving into the driver you&amp;#39;ll eventually end up in:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;__STATIC_INLINE void nrf_twim_address_set(NRF_TWIM_Type * p_reg,
                                          uint8_t address)
{
    p_reg-&amp;gt;ADDRESS = address;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Where &amp;#39;address&amp;#39; has not been modified in any way from what you pass to nrf_drv_twi_tx(). The&amp;nbsp;&lt;a title="  ADDRESS  " href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/twim.html?cp=4_2_0_32_7_17#register.ADDRESS"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;ADDRESS&lt;/a&gt;&amp;nbsp;register description declares that the ADDRESS register takes a 7-bit address without any bit-shifting.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;The R/W bit is added to the address depending on whether the&amp;nbsp;&lt;span&gt;TASKS_STARTRX or&amp;nbsp;TASKS_STARTTX task was triggered.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For the future I suggest you add test points to all serial I/O lines, as a digital scope will give you a lot more information than a peripheral driver who&amp;#39;s waiting for a reply from a slave who&amp;#39;s not listening.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/270964?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2020 04:35:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53508f24-80c7-4fe9-9001-48a405032e0c</guid><dc:creator>Leo Yang</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;hmolesworth, thanks for your fast response!&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;left shifted the slave address, with debug mode in Segger Embedded Studio, but I got stuck in&amp;nbsp;the while loop.(line 93)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    err_code = nrf_drv_twi_tx(&amp;amp;m_twi, ACC_ADDR, CTRL_REG1, sizeof(CTRL_REG1), false);
    APP_ERROR_CHECK(err_code);
    while (m_xfer_done == false); // &amp;lt;== stuck here&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It seems&amp;nbsp;that &amp;quot;m_xfer_done&amp;quot; was always false which means twi_handler() never returned to NRF_DRV_TWI_EVT_DONE state.&lt;/p&gt;
&lt;p&gt;I read the official documentation and it said a 7-bit address is needed.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1600832408170v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I thought the slave address(0x33U &amp;gt;&amp;gt; 1) is correct, because the LED_1 still blinks.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom NRF52832 + LIS2DH12 accelerometer but always get '0'</title><link>https://devzone.nordicsemi.com/thread/270932?ContentTypeID=1</link><pubDate>Tue, 22 Sep 2020 17:13:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7ffdd6e-7d56-40c8-a0b7-ac26bacbbb0a</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;As you know, &amp;quot;&lt;em&gt;If the SA0 pad is connected to the voltage supply, LSb is &amp;lsquo;1&amp;rsquo; (address 0011001b), else if the SA0 pad is connected to&amp;nbsp;ground, the LSb value is &amp;lsquo;0&amp;rsquo; (address 0011000b)&lt;/em&gt;.&amp;quot;&lt;/p&gt;
&lt;p&gt;This line doesn&amp;#39;t do what is intended:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define ACC_ADDR (0x33U &amp;gt;&amp;gt; 1)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;That &amp;#39;1&amp;#39; LS bit has just been discarded; this is often confusing with i2c, is the 7-bit address left- or right-shifted or not and the answer depends on the library. Check the function to see whether it actually&amp;nbsp;expects an un-shifted address.&lt;/p&gt;
&lt;p&gt;I would try this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define ACC_ADDR (0x33U &amp;lt;&amp;lt; 1)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The red LED works fine off a CR2032, but to get enough voltage for blue and green LEDs when the battery is low try adding another i/o pin and driving a capacitor with a diode clamp to provide voltage boost; the nRF52832 4-output PWM circuit is ideal for this - red/green/blue/boost, a common application made easy.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>