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

Unable to use TWI on nrf52840

Hi 

I am trying to use the TWI on nrf52840 but i am unable to get it to work. its getting stuck somewhere. I dont have a logic analyzer so i am unable to check if the signal are coming or not. I am able to use the I2C with apache mynewt so i dont think its the hardware problem. i have doubled checked the pin assignments for SCL and SDA as well. I have attached the code. Please help me out.

Output on the terminal:

<info> app: TWI scanner started
<info> app: Function return code: NRF_SUCCESS
<info> app: after twi_init

sdk_config.h

/**
 * Copyright (c) 2016 - 2018, 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 "AS IS" 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 tw_scanner main.c
 * @{
 * @ingroup nrf_twi_example
 * @brief TWI Sensor Example main file.
 *
 * This file contains the source code for a sample application using TWI.
 *
 */

#include <stdio.h>
#include "boards.h"
#include "app_util_platform.h"
#include "app_error.h"
#include "nrf_drv_twi.h"



#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"

/* TWI instance ID. */
#define TWI0_ENABLED 1
#define TWI_INSTANCE_ID     0

#define MPU9250_ADDRESS 0x68
#define WHO_AM_I_MPU9250 0x75 // Should return 0x71
#define CORRECT_RETURN 0x71

/* TWI instance. */
static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);



/**
 * @brief TWI initialization.
 */
void twi_init (void)
{
    ret_code_t err_code;

    const nrf_drv_twi_config_t twi_config = {
       .scl                = I2C_0_PIN_SCL,
       .sda                = I2C_0_PIN_SDA,
       .frequency          = I2C_0_FREQ_KHZ,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

    err_code = nrf_drv_twi_init(&m_twi, &twi_config, NULL, NULL);
    
    char const * p_desc = nrf_strerror_find(err_code);
    if (p_desc == NULL)
    {
        /* No human readable form found */
        NRF_LOG_INFO("Function return code: UNKNOWN (%x)", err_code);
    }
    else
    {
        /* Nice - mnemonic like - human readable form found */
        NRF_LOG_INFO("Function return code: %s", p_desc);
    }
     
    APP_ERROR_CHECK(err_code);
    nrf_drv_twi_enable(&m_twi);

}

/*
 * function to read sensor registers.
*/
ret_code_t read_register(nrf_drv_twi_t twi_instance, uint8_t device_addr, uint8_t register_addr, uint8_t *p_data, uint8_t bytes, bool no_stop)
{
  ret_code_t err_code;

  err_code = nrf_drv_twi_tx(&twi_instance, device_addr, &register_addr, 1, no_stop);
  APP_ERROR_CHECK(err_code);

  if(err_code != NRF_SUCCESS) {
    return err_code;
  }

  err_code = nrf_drv_twi_rx(&twi_instance, device_addr, p_data, bytes);
  return err_code;
}


/**
 * @brief Function for main application entry.
 */
int main(void)
{
    ret_code_t err_code;
    //uint8_t address;
    uint8_t sample_data;
    bool detected_device = false;

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO("TWI scanner started");
    NRF_LOG_FLUSH();
    twi_init();
    NRF_LOG_INFO("after twi_init");
	NRF_LOG_FLUSH();  


	err_code = read_register(m_twi, MPU9250_ADDRESS, WHO_AM_I_MPU9250, &sample_data, sizeof(sample_data), 0);

	char const * p_desc = nrf_strerror_find(err_code);
	if (p_desc == NULL)
	{
		/* No human readable form found */
		NRF_LOG_INFO("Function read_register code: UNKNOWN (%x)", err_code);
	}
	else
	{
		/* Nice - mnemonic like - human readable form found */
		NRF_LOG_INFO("Function read_register code: %s", p_desc);
	}
	NRF_LOG_FLUSH();
	
	if (err_code == NRF_SUCCESS)
	{
		detected_device = true;
		NRF_LOG_INFO("should be 0x71 but is 0x%02X", sample_data);
	}else{
		NRF_LOG_INFO("Failed!\n");
	}
	NRF_LOG_FLUSH();	
	
	
    if (!detected_device)
    {
        NRF_LOG_INFO("No device was found.");
        NRF_LOG_FLUSH();
    }

    while (true)
    {
        /* Empty loop. */
    }
}

/** @} */

Thanks.

Parents Reply Children
  • Hi.

    Can you please take a look at the debugging guide for Segger Embedded Studio?

    There is also one for Keil here.

    Best regards,

    Andreas

  • GNU gdb (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 8.0.50.20171128-git
    Copyright (C) 2017 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "--host=x86_64-pc-linux-gnu --target=arm-none-eabi".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>.
    Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.
    For help, type "help".
    Type "apropos word" to search for commands related to "word".
    (gdb) target extended-remote /dev/ttyACM0
    Remote debugging using /dev/ttyACM0
    (gdb) monitor swdp
    Target voltage: unknown
    Available Targets:
    No. Att Driver
     1      Nordic nRF52
     2      Nordic nRF52 Access Port
    (gdb) attach 1
    Attaching to Remote target
    warning: No executable has been specified and target does not support
    determining executable automatically.  Try using the "file" command.
    0x00003aa8 in ?? ()
    (gdb) file _build/nrf52840_xxaa.out
    A program is being debugged already.
    Are you sure you want to change the file? (y or n) y
    Reading symbols from _build/nrf52840_xxaa.out...done.
    (gdb) break nrf_drv_twi_tx
    Breakpoint 1 at 0x5e52: file ../../../../../../integration/nrfx/legacy/nrf_drv_twi.h, line 541.
    (gdb) run
    The program being debugged has been started already.
    Start it from the beginning? (y or n) y
    Starting program: /home/rohit/Documents/wearables/Implementation/nrf52840/code/NRFSDK/nRF5_SDK_15.2.0_9412b96/examples/peripheral/twi_scanner_rohit/pca10056/blank/armgcc/_build/nrf52840_xxaa.out 
    Note: automatically using hardware breakpoints for read-only addresses.
    
    Breakpoint 1, nrf_drv_twi_tx (p_instance=0x2003ffa0, address=104 'h', p_data=0x2003ffcc "u", length=1 '\001', no_stop=false)
        at ../../../../../../integration/nrfx/legacy/nrf_drv_twi.h:541
    541	    ret_code_t result = 0;
    (gdb) step
    544	        result = nrfx_twim_tx(&p_instance->u.twim,
    (gdb) step
    nrfx_twim_tx (p_instance=0x2003ffa4, address=104 'h', p_data=0x2003ffcc "u", length=1, no_stop=false)
        at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:505
    505	    nrfx_twim_xfer_desc_t xfer = NRFX_TWIM_XFER_DESC_TX(address, (uint8_t*)p_data, length);
    (gdb) step
    507	    return nrfx_twim_xfer(p_instance, &xfer, no_stop ? NRFX_TWIM_FLAG_TX_NO_STOP : 0);
    (gdb) step
    nrfx_twim_xfer (p_instance=0x2003ffa4, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:474
    474	    nrfx_err_t err_code = NRFX_SUCCESS;
    (gdb) step
    475	    twim_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
    (gdb) step
    492	    err_code = twim_xfer(p_cb, (NRF_TWIM_Type *)p_instance->p_twim, p_xfer_desc, flags);
    (gdb) step
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:306
    306	    nrfx_err_t err_code = NRFX_SUCCESS;
    (gdb) step
    307	    nrf_twim_task_t  start_task = NRF_TWIM_TASK_STARTTX;
    (gdb) step
    308	    nrf_twim_event_t evt_to_wait = NRF_TWIM_EVENT_STOPPED;
    (gdb) step
    310	    if (!nrfx_is_in_ram(p_xfer_desc->p_primary_buf))
    (gdb) step
    nrfx_is_in_ram (p_object=0x2003ffcc) at ../../../../../../modules/nrfx/drivers/nrfx_common.h:257
    257	    return ((((uint32_t)p_object) & 0xE0000000u) == 0x20000000u);
    (gdb) step
    258	}
    (gdb) step
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:319
    319	    nrf_twim_int_disable(p_twim, NRF_TWIM_ALL_INTS_MASK);
    (gdb) step
    nrf_twim_int_disable (p_reg=0x40003000, int_mask=27001346) at ../../../../../../modules/nrfx/hal/nrf_twim.h:414
    414	    p_reg->INTENCLR = int_mask;
    (gdb) step
    415	}
    (gdb) step
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:320
    320	    if (p_cb->busy)
    (gdb) 
    331	        p_cb->busy = ((NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER & flags) ||
    (gdb) 
    332	                      (NRFX_TWIM_FLAG_REPEATED_XFER & flags)) ? false: true;
    (gdb) 
    331	        p_cb->busy = ((NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER & flags) ||
    (gdb) 
    335	    p_cb->xfer_desc = *p_xfer_desc;
    (gdb) 
    336	    p_cb->repeated = (flags & NRFX_TWIM_FLAG_REPEATED_XFER) ? true : false;
    (gdb) 
    337	    nrf_twim_address_set(p_twim, p_xfer_desc->address);
    (gdb) 
    nrf_twim_address_set (p_reg=0x40003000, address=104 'h') at ../../../../../../modules/nrfx/hal/nrf_twim.h:460
    460	    p_reg->ADDRESS = address;
    (gdb) 
    461	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:339
    339	    nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_STOPPED);
    (gdb) 
    nrf_twim_event_clear (p_reg=0x40003000, event=NRF_TWIM_EVENT_STOPPED) at ../../../../../../modules/nrfx/hal/nrf_twim.h:374
    374	    *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
    (gdb) 
    376	    volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
    (gdb) 
    377	    (void)dummy;
    (gdb) 
    379	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:340
    340	    nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_ERROR);
    (gdb) 
    nrf_twim_event_clear (p_reg=0x40003000, event=NRF_TWIM_EVENT_ERROR) at ../../../../../../modules/nrfx/hal/nrf_twim.h:374
    374	    *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
    (gdb) 
    376	    volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
    (gdb) 
    377	    (void)dummy;
    (gdb) 
    379	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:342
    342	    twim_list_enable_handle(p_twim, flags);
    (gdb) 
    twim_list_enable_handle (p_twim=0x40003000, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:283
    283	    if (NRFX_TWIM_FLAG_TX_POSTINC & flags)
    (gdb) 
    289	        nrf_twim_tx_list_disable(p_twim);
    (gdb) 
    nrf_twim_tx_list_disable (p_reg=0x40003000) at ../../../../../../modules/nrfx/hal/nrf_twim.h:502
    502	    p_reg->TXD.LIST = 0;
    (gdb) 
    503	}
    (gdb) 
    twim_list_enable_handle (p_twim=0x40003000, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:292
    292	    if (NRFX_TWIM_FLAG_RX_POSTINC & flags)
    (gdb) 
    298	        nrf_twim_rx_list_disable(p_twim);
    (gdb) 
    nrf_twim_rx_list_disable (p_reg=0x40003000) at ../../../../../../modules/nrfx/hal/nrf_twim.h:512
    512	    p_reg->RXD.LIST = 0;
    (gdb) 
    513	}
    (gdb) 
    twim_list_enable_handle (p_twim=0x40003000, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:300
    300	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:343
    343	    switch (p_xfer_desc->type)
    (gdb) 
    387	        nrf_twim_tx_buffer_set(p_twim, p_xfer_desc->p_primary_buf, p_xfer_desc->primary_length);
    (gdb) 
    nrf_twim_tx_buffer_set (p_reg=0x40003000, p_buffer=0x2003ffcc "u", length=1) at ../../../../../../modules/nrfx/hal/nrf_twim.h:467
    467	    p_reg->TXD.PTR    = (uint32_t)p_buffer;
    (gdb) 
    468	    p_reg->TXD.MAXCNT = length;
    (gdb) 
    469	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:388
    388	        if (NRFX_TWIM_FLAG_TX_NO_STOP & flags)
    (gdb) 
    397	            nrf_twim_shorts_set(p_twim, NRF_TWIM_SHORT_LASTTX_STOP_MASK);
    (gdb) 
    nrf_twim_shorts_set (p_reg=0x40003000, shorts_mask=512) at ../../../../../../modules/nrfx/hal/nrf_twim.h:482
    482	    p_reg->SHORTS = shorts_mask;
    (gdb) 
    483	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:398
    398	            p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK | NRF_TWIM_INT_ERROR_MASK;
    (gdb) 
    400	        nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME);
    (gdb) 
    nrf_twim_task_trigger (p_reg=0x40003000, task=NRF_TWIM_TASK_RESUME) at ../../../../../../modules/nrfx/hal/nrf_twim.h:362
    362	    *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
    (gdb) 
    363	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:401
    401	        break;
    (gdb) 
    414	    if (!(flags & NRFX_TWIM_FLAG_HOLD_XFER) && (p_xfer_desc->type != NRFX_TWIM_XFER_TXTX))
    (gdb) 
    416	        nrf_twim_task_trigger(p_twim, start_task);
    (gdb) 
    nrf_twim_task_trigger (p_reg=0x40003000, task=NRF_TWIM_TASK_STARTTX) at ../../../../../../modules/nrfx/hal/nrf_twim.h:362
    362	    *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
    (gdb) 
    363	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:419
    419	    if (p_cb->handler)
    (gdb) 
    441	        while (!nrf_twim_event_check(p_twim, evt_to_wait))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_STOPPED) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:443
    443	            if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_ERROR))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_ERROR) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:441
    441	        while (!nrf_twim_event_check(p_twim, evt_to_wait))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_STOPPED) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:443
    443	            if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_ERROR))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_ERROR) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:441
    441	        while (!nrf_twim_event_check(p_twim, evt_to_wait))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_STOPPED) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:443
    443	            if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_ERROR))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_ERROR) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:441
    441	        while (!nrf_twim_event_check(p_twim, evt_to_wait))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_STOPPED) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:443
    443	            if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_ERROR))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_ERROR) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:441
    441	        while (!nrf_twim_event_check(p_twim, evt_to_wait))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_STOPPED) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:443
    443	            if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_ERROR))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_ERROR) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:441
    441	        while (!nrf_twim_event_check(p_twim, evt_to_wait))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_STOPPED) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:443
    443	            if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_ERROR))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_ERROR) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:441
    441	        while (!nrf_twim_event_check(p_twim, evt_to_wait))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_STOPPED) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:443
    443	            if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_ERROR))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_ERROR) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:441
    441	        while (!nrf_twim_event_check(p_twim, evt_to_wait))
    (gdb) 
    nrf_twim_event_check (p_reg=0x40003000, event=NRF_TWIM_EVENT_STOPPED) at ../../../../../../modules/nrfx/hal/nrf_twim.h:384
    384	    return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
    (gdb) 
    385	}
    (gdb) 
    twim_xfer (p_cb=0x20000850 <m_cb>, p_twim=0x40003000, p_xfer_desc=0x2003ff54, flags=0) at ../../../../../../modules/nrfx/drivers/src/nrfx_twim.c:443
    443	            if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_ERROR))
    (gdb) quit
    A debugging session is active.
    
    	Inferior 1 [Remote target] will be killed.
    
    Quit anyway? (y or n) y
    

    I hope this helps.

  • I tried by uploading the generated hex file directly and it works. But when i create a zip file using nrfutil for usb-dfu, it shows the "stuck" behaviour i have been describing in this post. Can you please help me out? I am using SDK nRF5_SDK_15.2.0_9412b96 . 

    I created the zip file using nrfutil pkg generate --debug-mode --hw-version 52 --sd-req 0 --application _build/nrf52840_xxaa.hex trial.zip

    and i am using the open_bootloader example.

    
    /* Linker script to configure memory regions. */
    
    SEARCH_DIR(.)
    GROUP(-lgcc -lc -lnosys)
    
    MEMORY
    {
      FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0xff000
      RAM (rwx) :  ORIGIN = 0x20000000, LENGTH = 0x40000
    }
    
    SECTIONS
    {
    }
    
    SECTIONS
    {
      . = ALIGN(4);
      .mem_section_dummy_ram :
      {
      }
      .log_dynamic_data :
      {
        PROVIDE(__start_log_dynamic_data = .);
        KEEP(*(SORT(.log_dynamic_data*)))
        PROVIDE(__stop_log_dynamic_data = .);
      } > RAM
      .log_filter_data :
      {
        PROVIDE(__start_log_filter_data = .);
        KEEP(*(SORT(.log_filter_data*)))
        PROVIDE(__stop_log_filter_data = .);
      } > RAM
    
    } INSERT AFTER .data;
    
    SECTIONS
    {
      .mem_section_dummy_rom :
      {
      }
      .log_const_data :
      {
        PROVIDE(__start_log_const_data = .);
        KEEP(*(SORT(.log_const_data*)))
        PROVIDE(__stop_log_const_data = .);
      } > FLASH
      .log_backends :
      {
        PROVIDE(__start_log_backends = .);
        KEEP(*(SORT(.log_backends*)))
        PROVIDE(__stop_log_backends = .);
      } > FLASH
        .nrf_balloc :
      {
        PROVIDE(__start_nrf_balloc = .);
        KEEP(*(.nrf_balloc))
        PROVIDE(__stop_nrf_balloc = .);
      } > FLASH
    
    } INSERT AFTER .text
    
    INCLUDE "nrf_common.ld"
    

    Also are there any resource for linker files in nrf SDK?

    Thanks

Related