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

Control Stuck at Soft device region 0 address at 0x6b0(sometimes at 0x640)

Hi,

   We are using nrf51822 QFAAH00 with SDK 110 v8.1.0 in our project, the application will hangs or not work when control stuck at address 0x6b0 (sometimes at 0x640) programmer in debug mode.

Sometimes code hangs in hardware fault loop,if i put break point before that instruction code where it is hangs, control has to be stop at break point instruction, But  when we view from call stack register control is stuck after the break point.

Linker Configuration  .icf configured as below :

define symbol __ICFEDIT_intvec_start__ = 0x00018000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00018000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20002000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x800;
define symbol __ICFEDIT_size_heap__ = 0x200;
/**** End of ICF editor section. ###ICF###*/  

Thank,

Nagaraj

Parents
  • FormerMember
    0 FormerMember

    What does the application do before it starts hanging? Which functions are being called?

    If you use logging over UART/RTT what is going on before the application hangs?

    Does this problem only occur in debug mode?

  • Hi Kristin,

    Our Application will send battery status to central Device (Mobile app), able to communicate with central device but sometimes hangs in Soft-Device address.  

    We have tried with increasing the C-stack size up to 3 Kb for Soft-device and Application. When we comment the advertising part the code didn't hang in this case.

    We are not able to exactly locate the cause for the issue as sometimes the code will  not hang for hours, but sometimes the code will hang immediately as soon as we reset the board.

    This problem occurred in Debug mode as well as in release mode also.

    Let me know if you want more details.

                                                                                                                    

                                                                                                                       Log File

    Thanks,

    Nagaraj

  • Hi,

         Waiting for your reply, Application  hangs in control hard-fault and sometimes in soft-device lower address, This is happening not while Bluetooth stack initialization. 

    Thanks,

    Nagaraj

  • FormerMember
    0 FormerMember in reply to nagaraj

    Could you upload the code here? (If you want to keep the code confidential, you can switch the case to a private case.)

    Is there any difference in running the application when the chip has newly been fully erased, and when it has not? (In terms of how much time it takes before the application crash.)

  • Hi,

    As per Company policy we cannot share the source code, Application will run sometimes more than hour or sometimes hangs after 5-10 mintues. Application will work without softdevice .

    We using the I2C0, UART0, TIMER2 ,GPIOTE which are interrupt based, In Application every 2sec we reading registers through i2c.

    We tried different priority level with  I2C0, UART0, TIMER2 , GPIOTE, results in same control hardfault loop, when we check debug mode in call stack after hardfault sometimes control stuck in i2c read function. 

    • I2C Priority Level: 1, UART Priority Level: 3, TIMER2  Priority Level: 3, GPIOTE Priority Level: 3
    • I2C Priority Level: 1, UART Priority Level: 3, TIMER2  Priority Level: 1, GPIOTE Priority Level: 3
    • I2C Priority Level: 3, UART Priority Level: 3, TIMER2  Priority Level: 3, GPIOTE Priority Level: 3
    • I2C Priority Level: 1, UART Priority Level: 1, TIMER2  Priority Level: 1, GPIOTE Priority Level: 1

    Thanks,

    Nagaraj

Reply
  • Hi,

    As per Company policy we cannot share the source code, Application will run sometimes more than hour or sometimes hangs after 5-10 mintues. Application will work without softdevice .

    We using the I2C0, UART0, TIMER2 ,GPIOTE which are interrupt based, In Application every 2sec we reading registers through i2c.

    We tried different priority level with  I2C0, UART0, TIMER2 , GPIOTE, results in same control hardfault loop, when we check debug mode in call stack after hardfault sometimes control stuck in i2c read function. 

    • I2C Priority Level: 1, UART Priority Level: 3, TIMER2  Priority Level: 3, GPIOTE Priority Level: 3
    • I2C Priority Level: 1, UART Priority Level: 3, TIMER2  Priority Level: 1, GPIOTE Priority Level: 3
    • I2C Priority Level: 3, UART Priority Level: 3, TIMER2  Priority Level: 3, GPIOTE Priority Level: 3
    • I2C Priority Level: 1, UART Priority Level: 1, TIMER2  Priority Level: 1, GPIOTE Priority Level: 1

    Thanks,

    Nagaraj

Children
  • FormerMember
    0 FormerMember in reply to nagaraj

    Okay, I see. By priority level, does the priority levels correspond to these priority levels?

    #define _PRIO_SD_HIGH       0
    #define _PRIO_SD_MID        1
    #define _PRIO_APP_HIGH      2
    #define _PRIO_APP_MID       3
    #define _PRIO_SD_LOW        4
    #define _PRIO_SD_LOWEST     5
    #define _PRIO_APP_LOW       6
    #define _PRIO_APP_LOWEST    7
    #define _PRIO_THREAD        15

    typedef enum
    {
    #ifndef SOFTDEVICE_PRESENT
        APP_IRQ_PRIORITY_HIGHEST = _PRIO_SD_HIGH,
    #else
        APP_IRQ_PRIORITY_HIGHEST = _PRIO_APP_HIGH,
    #endif
        APP_IRQ_PRIORITY_HIGH    = _PRIO_APP_HIGH,
    #ifndef SOFTDEVICE_PRESENT
        APP_IRQ_PRIORITY_MID     = _PRIO_SD_LOW,
    #else
        APP_IRQ_PRIORITY_MID     = _PRIO_APP_MID,
    #endif
        APP_IRQ_PRIORITY_LOW     = _PRIO_APP_LOW,
        APP_IRQ_PRIORITY_LOWEST  = _PRIO_APP_LOWEST,
        APP_IRQ_PRIORITY_THREAD  = _PRIO_THREAD     /**< "Interrupt level" when running in Thread Mode. */
    } app_irq_priority_t;

     What happens if you set the priority of  I2C0, UART0, TIMER2 , GPIOTE to APP_IRQ_PRIORITY_LOWEST and the softdevice to APP_IRQ_PRIORITY_LOW? So that the softdevice and the softdevice events always will have higher priority?

  • Hi,

     We are using S110 v8.1.0, As per soft-device S110_SDS_V2 priority levels up to 0 - 3 available in Code.  app_util_platform.h

     

    After Application hangs, when we check CSTACK address of 0x20002E34 holds value of 0xFFFFFFF9, What is 0xFFFFFFF9 indicates. Is this causing any issue.

    Thanks,

    Nagaraj 

  • FormerMember
    0 FormerMember in reply to nagaraj

    Which version of the SDK do you use?

    Could you have a look at this thread, could the problem be similar to the one in that thread?

  • Hi,

       we are using SDK v8.1.0, didn't use APP_TWI_INIT function to initialize the i2c, we have written the drivers for i2c initialization. 

    We have set CSTACK size to 3k and Heap Size to 0, As per S110 SDS_v2 Document CSTACK has to start from address  0x20003fff to 0x20003402, but in our Application Cstack address starts from 0x20002e96 to 0x20002298. 

    Our Application RAM usage:

     Application RAM address starts from  0x20002000 to 0x20002295, followed by CSTACK address  0x20002e96 to 0x20002298, followed by Application RAM address starts from 0x20002e98 to 0x20003c5f, but it has to be readwrite,Heap,CSTACk in this order as per S110 SDS_v2 . why it is so? 

    After Application hangs, when we check call stack contains [NRF_POWER_RAMONx_RAMxON_ONMODE_Msk + 0x6ad] in debug mode, what this indicate? 

    /**
     * \file i2c.c
     * \brief nRF51822 I2C driver file
    
     * \author	Sowmya B R
     * \date 2015-09-29
    
     * \version	0.1
     */
    
    /*
     *  --------------------- INCLUDE FILES ---------------------
     */
    
    #include <stdint.h>
    #include <stdbool.h>
    
    #include <nrf51.h>
    #include <nrf_delay.h>
    #include <nrf_drv_common.h>
    #include <app_util_platform.h>
    
    #include "drivers/i2c.h"
    
    
    /*
     *  --------------------- DEFINITION ---------------------
     */
    
    
    
    /*
     *  --------------------- Global variables ---------------------
     */
    
    
    static uint32_t Addr_Size;
    
    /*
     *  --------------------- FUNCTION DECLARATION ---------------------
     */
    
    /*
     *  --------------------- FUNCTION BODY ---------------------
     */
    
    void i2c_init(st_i2c_config * StI2C)
    {
    	NRF_GPIO->PIN_CNF[StI2C->Clock_Pin] = ((GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
                                | (GPIO_PIN_CNF_DRIVE_S0D1     << GPIO_PIN_CNF_DRIVE_Pos)
                                | (GPIO_PIN_CNF_PULL_Pullup    << GPIO_PIN_CNF_PULL_Pos)
                                | (GPIO_PIN_CNF_INPUT_Connect  << GPIO_PIN_CNF_INPUT_Pos)
                                | (GPIO_PIN_CNF_DIR_Input      << GPIO_PIN_CNF_DIR_Pos));
    	
    	NRF_GPIO->PIN_CNF[StI2C->Data_Pin] = ((GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
                                | (GPIO_PIN_CNF_DRIVE_S0D1     << GPIO_PIN_CNF_DRIVE_Pos)
                                | (GPIO_PIN_CNF_PULL_Pullup    << GPIO_PIN_CNF_PULL_Pos)
                                | (GPIO_PIN_CNF_INPUT_Connect  << GPIO_PIN_CNF_INPUT_Pos)
                                | (GPIO_PIN_CNF_DIR_Input      << GPIO_PIN_CNF_DIR_Pos));
    	// set frequency
    	StI2C->nRF_I2C->FREQUENCY = StI2C->Frequency << TWI_FREQUENCY_FREQUENCY_Pos;
    	// configure i2c clock and data lines
    	StI2C->nRF_I2C->PSELSCL = StI2C->Clock_Pin;
    	StI2C->nRF_I2C->PSELSDA = StI2C->Data_Pin;
    
    	StI2C->nRF_I2C->INTENSET = TWI_INTENSET_TXDSENT_Msk | TWI_INTENSET_STOPPED_Msk | TWI_INTENSET_RXDREADY_Msk;
    	StI2C->nRF_I2C->ENABLE = TWI_ENABLE_ENABLE_Enabled << TWI_ENABLE_ENABLE_Pos;
    }
    
    void i2c_start(st_i2c_config * stI2C)
    {
    	stI2C->nRF_I2C->ADDRESS = stI2C->Device->Slave;			// transmit slave id
    	Addr_Size = stI2C->Device->Addr_Size;
       
    	if(Addr_Size > 0)
    	{
    		Addr_Size--;
    		stI2C->nRF_I2C->TXD = stI2C->Device->Address.u8[Addr_Size];
    		// transmit the address
                 // stI2C->nRF_I2C->EVENTS_RXDREADY = 0;
                    stI2C->nRF_I2C->TASKS_STARTTX = 1;
    	}
    	else
    	{    
              stI2C->nRF_I2C->TASKS_STARTRX = 1;
             // stI2C->nRF_I2C->TASKS_STOP = 1;	
    		//return;
    	}
    	//stI2C->nRF_I2C->TASKS_STARTTX = 1;
    }
    
    void i2c_irq_handler(st_i2c_config* stI2C)
    {
    	if(stI2C->nRF_I2C->EVENTS_TXDSENT != 0)
    	{
    		stI2C->nRF_I2C->EVENTS_TXDSENT = 0;
    		
    		if(Addr_Size > 0)				// Is Address is there?
    		{
    			Addr_Size--;
    			stI2C->nRF_I2C->TXD = stI2C->Device->Address.u8[Addr_Size];
    		}
    		else if(stI2C->Device->Tx_Quantity)
    		{
    			stI2C->nRF_I2C->TXD = *stI2C->Device->Buffer++;
    			stI2C->Device->Tx_Quantity--;
    		}
    		else
    		{
    			if(stI2C->Device->Rx_Quantity == 0)
    			{
    				stI2C->nRF_I2C->TASKS_STOP = 1;			// write complete
    			}
                            else
                               stI2C->nRF_I2C->TASKS_STARTRX = 1;			// repeated start
    		}
    	}
    	
    	if(stI2C->nRF_I2C->EVENTS_STOPPED)
    	{
    		stI2C->nRF_I2C->EVENTS_STOPPED = 0;
    		stI2C->Device->Operation_Complete = true;
    	}
    	
    	if(stI2C->nRF_I2C->EVENTS_RXDREADY != 0)
    	{
    		stI2C->nRF_I2C->EVENTS_RXDREADY = 0;
    		*stI2C->Device->Buffer++ = stI2C->nRF_I2C->RXD;
    		if(--stI2C->Device->Rx_Quantity > 0)
                    {
                      stI2C->nRF_I2C->TASKS_RESUME = 1;
                    }
                    else
                    {
    		  stI2C->nRF_I2C->TASKS_STOP = 1;		// read complete
    		}
    	}
            // Handle errors.
            //if (stI2C->nRF_I2C->EVENTS_ERROR != 0)
    	//{
    		//stI2C->nRF_I2C->EVENTS_ERROR = 0;		// Clear UART ERROR event flag.
    		// Clear error source.
    	//}
    }
    
    /*
     *  --------------------- End Of File ---------------------
     */
    
    /**
     * \file i2c_0.c
     * \brief
    
     * \author	Sowmya B R
     * \date 2015-09-30
    
     * \version	0.1
     */
    
    /*
     *  --------------------- INCLUDE FILES ---------------------
     */
    
    #include <stdbool.h>
    #include <nrf51.h>
    #include <nrf_delay.h>
    #include <app_util_platform.h>
    
    #include "drivers/i2c.h"
    #include "drivers/i2c_0.h"
    #include "drivers/gpio.h"
    
    /*
     *  --------------------- DEFINITION ---------------------
     */
    
    /*
     *  --------------------- Global variables ---------------------
     */
    
    st_i2c_config I2C_0 = 
    {
    	.Clock_Pin   = TWI_MASTER_CLOCK_PIN,
    	.Data_Pin    = TWI_MASTER_DATA_PIN,
    	.Frequency   = TWI_FREQUENCY_FREQUENCY_K100,
            .nRF_I2C     = NRF_TWI0,
    	//.PPI_Channel = PPI_CHANNEL,
            
    };
    
    /*
     *  --------------------- FUNCTION DECLARATION ---------------------
     */
    
    /*
     *  --------------------- FUNCTION BODY ---------------------
     */
    
    void SPI0_TWI0_IRQHandler(void)
    {
    	i2c_irq_handler(&I2C_0);
    }
    
    void init_i2c_0()
    {
    	//I2C_0.Frequency = Frequency;
    	i2c_init(&I2C_0);
    	
    	//NVIC_SetPriority(SPI0_TWI0_IRQn, APP_IRQ_PRIORITY_LOW);
    	//NVIC_ClearPendingIRQ(SPI0_TWI0_IRQn);
    	//NVIC_EnableIRQ(SPI0_TWI0_IRQn);	
       
           sd_nvic_SetPriority(SPI0_TWI0_IRQn,APP_IRQ_PRIORITY_HIGH);
           sd_nvic_ClearPendingIRQ(SPI0_TWI0_IRQn);
           sd_nvic_EnableIRQ(SPI0_TWI0_IRQn);
    }
    
    /*
     *  --------------------- End Of File ---------------------
     */
    

  • Hi,

        Waiting for your reply, please respond to above mentioned issue.

    Thanks,

    Nagaraj 

Related