Hi I have a custom board that has a dwm3001c and I want to running test_reading dev_id but when ı call dwt_probe my software enter to hardfault_handler.
I have dw3000 api and ı change nrf52840 with nrf52833
I add SEGGER_FLASH.icf
define exported symbol __dw_drivers_start = 0x08001180;
define exported symbol __dw_drivers_end = 0x0800119F;
define region TEXT_DW_region = mem:[from __dw_drivers_start to __dw_drivers_end];
define block DW_DRIVERS with alignment = 4 { section .dw_drivers};
place in TEXT_DW_region { block DW_DRIVERS};
my section placement macros :
FLASH_PH_START=0x0
FLASH_PH_SIZE=0x80000
RAM_PH_START=0x20000000
RAM_PH_SIZE=0x20000
FLASH_START=0x0
FLASH_SIZE=0x59000
FCONFIG_START=0x10000
FCONFIG_SIZE=0x400
DEFAULT_CONFIG_START=0x10500
DEFAULT_CONFIG_SIZE=0x400
INIT_START=0x12000
RAM_START=0x20000000
RAM_SIZE=0x40000
my memory segment:
FLASH RX 0x0 0x100000;RAM1 RWX 0x20000000 0x40000
my additional linker option :
–whole-archive
C:/Users/fyavuz/Desktop/nRF5_SDK_17.1.0_ddde560_FY/examples/Shared/dwt_uwb_driver/lib/libdwt_uwb_driver-m4-hfp-6.0.7.a
–no-whole-archive
my preprocessors definitions :
BOARD_PCA10100
CONFIG_GPIO_AS_PINRESET
FLOAT_ABI_HARD
INITIALIZE_USER_SECTIONS
NO_VTOR_CONFIG
NRF52833_XXAA
DEBUG
and I added system_nrf52833.c, ses_startup_nrf52833.s and I delete system_nrf52840.c, ses_startup_nrf52840.s
my port.h :
#ifndef PORT_H_
#define PORT_H_
#ifdef __cplusplus
extern “C”
{
#endif
#include <boards.h>
#include <sdk_config.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#if defined(BOARD_PCA10040)
#include <pca10040.h>
#elif defined(BOARD_PCA10056)
#include <pca10056.h>
#endif
#include “deca_spi.h”
#include <nrf_delay.h>
#include <nrf_drv_gpiote.h>
#include <nrf_error.h>
/* ENABLE_USB_PRINT Macro is uncommented then Segger RTT Print will be enabled*/
#define ENABLE_USB_PRINT
/* DW IC IRQ handler type. */
typedef void (*port_dwic_isr_t)(void);
/*****************************************************************************************************************/ /*
**/
/****************************************************************************
*
* Types definitions
*
*******************************************************************************/
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
/****************************************************************************
*
* MACRO
*
*******************************************************************************/
#define DW3000_IRQn_Pin 34
#define DW3000_RESET_Pin 25
#define DW3000_WAKEUP_Pin ARDUINO_9_PIN
#define DW3000_IRQ2n_Pin 30//ARDUINO_6_PIN
// SPI defs
#define DW3000_CS_Pin 38//SPIS_CSN_PIN//ARDUINO_10_PIN
#define DW3000_CLK_Pin 19//SPI3_CONFIG_SCK_PIN//ARDUINO_13_PIN // DWM3000 shield SPIM1 sck connected to DW3000
#define DW3000_MOSI_Pin 8//SPI3_CONFIG_MOSI_PIN//ARDUINO_11_PIN // DWM3000 shield SPIM1 mosi connected to DW3000
#define DW3000_MISO_Pin 28//SPI3_CONFIG_MISO_PIN//ARDUINO_12_PIN // DWM3000 shield SPIM1 miso connected to DW3000
//This set the IO for waking up the chip
#define SET_WAKEUP_PIN_IO_LOW nrf_gpio_pin_clear(DW3000_WAKEUP_Pin)
#define SET_WAKEUP_PIN_IO_HIGH nrf_gpio_pin_set(DW3000_WAKEUP_Pin)
/This is should be a delay of 500uSec at least. In our example it is more than that/
#define WAIT_500uSEC nrf_delay_us(500)
/This is should be a delay of 200uSec at least. In our example it is more than that/
#define WAIT_200uSEC nrf_delay_us(200)
/****************************************************************************
*
* MACRO function
*
*******************************************************************************/
/****************************************************************************
*
* port function prototypes
*
*******************************************************************************/
/* @fn Sleep
* @brief Sleep delay in ms using SysTick timer
* */
void Sleep(uint32_t x);
/* @fn peripherals_init
* No perifpherals used in this port.
* */
int peripherals_init(void);
/* @fn gpio_init
-
@brief Initialises the GPIOs of nRF52840-DK board
-
*/
void gpio_init(void);/* @fn reset_DW IC
- @brief DW_RESET pin on DW IC has 2 functions
-
In general it is output, but it also can be used to reset the digital
-
part of DW IC by driving this pin low.
-
Note, the DW_RESET pin should not be driven high externally.
- */
void reset_DWIC(void);
/*! ------------------------------------------------------------------------------------------------------------------
- @fn wakeup_device_with_io()
- @brief This function wakes up the device by toggling io with a delay.
- input None
- output -None
*/
void wakeup_device_with_io(void);/*! ------------------------------------------------------------------------------------------------------------------
- @fn make_very_short_wakeup_io()
- @brief This will toggle the wakeup pin for a very short time. The device should not wakeup
- input None
- output -None
*/
void make_very_short_wakeup_io(void);/* @fn process_deca_irq
- @brief main call-back for processing of DW3000 IRQ
-
it re-enters the IRQ routing and processes all events.
-
After processing of all events, DW3000 will clear the IRQ line.
- */
void process_deca_irq(void);
/* @fn port_DisableEXT_IRQ
- @brief wrapper to disable DW_IRQ pin IRQ
- */
void port_DisableEXT_IRQ(void);
/* @fn port_EnableEXT_IRQ
- @brief wrapper to enable DW_IRQ pin IRQ
- */
void port_EnableEXT_IRQ(void);
/* @fn port_GetEXT_IRQStatus
- @brief wrapper to read a DW_IRQ pin IRQ status
- */
uint32_t port_GetEXT_IRQStatus(void);
/* @fn port_CheckEXT_IRQ
- @brief wrapper to read DW_IRQ input pin state
- */
uint32_t port_CheckEXT_IRQ(void);
/* @fn dw_irq_init
- @brief wrapper to configure IRQ
- */
void dw_irq_init(void);
/*! ------------------------------------------------------------------------------------------------------------------
- @fn port_set_dwic_isr()
- @brief This function is used to install the handling function for DW IC IRQ.
- NOTE:
-
- The user application shall ensure that a proper handler is set by calling this function before any DW IC IRQ occurs.
-
- This function deactivates the DW IC IRQ line while the handler is installed.
- @param deca_isr function pointer to DW IC interrupt handler to install
-
@return none
*/
void port_set_dwic_isr(port_dwic_isr_t dwic_isr);
#ifdef __cplusplus
}
#endif
#endif /* PORT_H_ */
my sdk_config.h:
#ifndef NRFX_CLOCK_CONFIG_LF_SRC
#define NRFX_CLOCK_CONFIG_LF_SRC 0
#endif
// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer
//==========================================================
#ifndef SPIS_ENABLED
#define SPIS_ENABLED 1
#endif
// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority
// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
// <0=> 0 (highest)
// <1=> 1
// <2=> 2
// <3=> 3
// <4=> 4
// <5=> 5
// <6=> 6
// <7=> 7
#ifndef SPIS_DEFAULT_CONFIG_IRQ_PRIORITY
#define SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6
#endif
// SPIS_DEFAULT_MODE - Mode
// <0=> MODE_0
// <1=> MODE_1
// <2=> MODE_2
// <3=> MODE_3
#ifndef SPIS_DEFAULT_MODE
#define SPIS_DEFAULT_MODE 0
#endif
// SPIS_DEFAULT_BIT_ORDER - SPIS default bit order
// <0=> MSB first
// <1=> LSB first
#ifndef SPIS_DEFAULT_BIT_ORDER
#define SPIS_DEFAULT_BIT_ORDER 0
#endif
// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255>
#ifndef SPIS_DEFAULT_DEF
#define SPIS_DEFAULT_DEF 255
#endif
// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255>
#ifndef SPIS_DEFAULT_ORC
#define SPIS_DEFAULT_ORC 255
#endif
// SPIS0_ENABLED - Enable SPIS0 instance
#ifndef SPIS0_ENABLED
#define SPIS0_ENABLED 0
#endif
// SPIS1_ENABLED - Enable SPIS1 instance
#ifndef SPIS1_ENABLED
#define SPIS1_ENABLED 0
#endif
// SPIS2_ENABLED - Enable SPIS2 instance
#ifndef SPIS2_ENABLED
#define SPIS2_ENABLED 0
#endif
//
// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer
//==========================================================
#ifndef SPI_ENABLED
#define SPI_ENABLED 1
#endif
// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority
// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
// <0=> 0 (highest)
// <1=> 1
// <2=> 2
// <3=> 3
// <4=> 4
// <5=> 5
// <6=> 6
// <7=> 7
#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY
#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 7
#endif
// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration.
// <0=> NRF_GPIO_PIN_NOPULL
// <1=> NRF_GPIO_PIN_PULLDOWN
// <3=> NRF_GPIO_PIN_PULLUP
#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG
#define NRF_SPI_DRV_MISO_PULLUP_CFG 1
#endif
// SPI0_ENABLED - Enable SPI0 instance
//==========================================================
#ifndef SPI0_ENABLED
#define SPI0_ENABLED 1
#endif
// SPI0_USE_EASY_DMA - Use EasyDMA
#ifndef SPI0_USE_EASY_DMA
#define SPI0_USE_EASY_DMA 1
#endif
//
// SPI1_ENABLED - Enable SPI1 instance
//==========================================================
#ifndef SPI1_ENABLED
#define SPI1_ENABLED 0
#endif
// SPI1_USE_EASY_DMA - Use EasyDMA
#ifndef SPI1_USE_EASY_DMA
#define SPI1_USE_EASY_DMA 1
#endif
//
// SPI2_ENABLED - Enable SPI2 instance
//==========================================================
#ifndef SPI2_ENABLED
#define SPI2_ENABLED 2
#endif
// SPI2_USE_EASY_DMA - Use EasyDMA
#ifndef SPI2_USE_EASY_DMA
#define SPI2_USE_EASY_DMA 1
#endif
#define SPI0_CONFIG_SCK_PIN 16
#define SPI0_CONFIG_MOSI_PIN 20
#define SPI0_CONFIG_MISO_PIN 21
#define SPI0_CONFIG_IRQ_PRIORITY (APP_IRQ_PRIORITY_MID - 2)
#define SPI0_INSTANCE_INDEX 0
//
// SPI3_ENABLED - Enable SPI3 instance
//==========================================================
#ifndef SPI3_ENABLED
#define SPI3_ENABLED 3
#endif
// SPI3_USE_EASY_DMA - Use EasyDMA
#ifndef SPI3_USE_EASY_DMA
#define SPI3_USE_EASY_DMA 1
#endif
//#define SPI3_USE_EASY_DMA 1
#define SPI3_CONFIG_SCK_PIN 19
#define SPI3_CONFIG_MOSI_PIN 8
#define SPI3_CONFIG_MISO_PIN 28
#define SPI3_CONFIG_IRQ_PRIORITY (APP_IRQ_PRIORITY_MID - 2)
#define SPI3_INSTANCE_INDEX (SPI3_ENABLED)
#define SPI2_INSTANCE_INDEX (SPI2_ENABLED)
//#define SPI1_INSTANCE_INDEX (SPI1_ENABLED)
//#define SPI0_INSTANCE_INDEX (SPI0_ENABLED)
#ifndef NRFX_SPIM3_NRF52840_ANOMALY_198_WORKAROUND_ENABLED
#define NRFX_SPIM3_NRF52840_ANOMALY_198_WORKAROUND_ENABLED 1
#endif
//
MY MAİN.C :
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals (if attached). */
build_examples();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
bsp_board_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS);
/* Initialise nRF52840-DK GPIOs */
gpio_init();
/* Initialise the SPI for nRF52840-DK */
nrf52840_dk_spi_init();
/* Configuring interrupt*/
dw_irq_init();
/* Small pause before startup */
nrf_delay_ms(2);
if (UNIT_TEST)
{
unit_test_main();
}
else
{
// Run the selected example as selected in example_selection.h
example_pointer();
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
void nrf52840_dk_spi_init(void)
{
nrf_drv_spi_t *spi_inst;
nrf_drv_spi_config_t *spi_config;
spi_handle_t *pSPI_handler = SPI->pSpi;
pSPI_handler->frequency_slow = NRF_SPIM_FREQ_4M;
pSPI_handler->frequency_fast = NRF_SPIM_FREQ_32M;
pSPI_handler->lock = DW_HAL_NODE_UNLOCKED;
spi_inst = &pSPI_handler->spi_inst;
spi_config = &pSPI_handler->spi_config;
spi_inst->inst_idx = SPI3_INSTANCE_INDEX;
spi_inst->use_easy_dma = SPI3_USE_EASY_DMA;
spi_inst->u.spim.p_reg = NRF_SPIM3;
spi_inst->u.spim.drv_inst_idx = NRFX_SPIM3_INST_IDX;
spi_config->sck_pin = DW3000_CLK_Pin;
spi_config->mosi_pin = DW3000_MOSI_Pin;
spi_config->miso_pin = DW3000_MISO_Pin;
spi_config->ss_pin = NRF_DRV_SPI_PIN_NOT_USED;
spi_config->irq_priority = (APP_IRQ_PRIORITY_MID - 2);
spi_config->orc = 0xFF;
spi_config->frequency = NRF_SPIM_FREQ_4M;
spi_config->mode = NRF_DRV_SPI_MODE_0;
spi_config->bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST;
// Configure the chip select as an output pin that can be toggled
nrf_drv_gpiote_out_config_t out_config = NRFX_GPIOTE_CONFIG_OUT_TASK_TOGGLE(NRF_GPIOTE_INITIAL_VALUE_HIGH);
nrf_drv_gpiote_out_init(DW3000_CS_Pin, &out_config);
}
AND;
void dw_irq_init(void)
{
ret_code_t err_code;
nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
in_config.pull = NRF_GPIO_PIN_PULLDOWN;
err_code = nrf_drv_gpiote_in_init(DW3000_IRQn_Pin, &in_config, deca_irq_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(DW3000_IRQn_Pin, false);
nrf_gpio_cfg_output(DW3000_WAKEUP_Pin);
err_code = nrf_drv_gpiote_in_init(DW3000_IRQ2n_Pin, &in_config, deca_irq_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(DW3000_IRQ2n_Pin, false);
}
my hardware: