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,

       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 

  • FormerMember
    0 FormerMember in reply to nagaraj

    The debugging continues in this thread.

  • Hi,

       please reply for previous posted comment, Application and SDK RAM usage in our project.

    how to distinguish the call-stack address for SDK and our Application. 

    Thanks,

    Nagaraj 

  • FormerMember
    0 FormerMember in reply to nagaraj

    The SDK and the application will be one "unit" so it will not be possible to distinguish them .

    If setting NRF_POWER->RAMON, RAM data in the specified blocks will be kept in SYSTEM OFF.

Reply Children
No Data
Related