HardFault after GPIO PIN set to High on Custom Board

Hi,

on my Custom Board I'am setting P0.12 to High triggered by a BLE notification (NUS). I'am here using the BLE Uart Example (S112, pca10040). The Custom Board's nrf52832 DCDC Pin is not connected

The Problem is, that on my Custom Board the System goes direct in the Hard Fault on the nrf52 DK not. Is there something in for P0.12 in use somewhere else?

P0.12 is bounded to an STM32 MCU's boot0 Pin with a external 10k pulldown.

if (p_evt->type == BLE_CTRL)
{

if (p_evt->params.rx_data.p_data[0]==0xFA)
{ // Bootloader Pattern1
m_ctrl=1;
nrf_gpio_pin_write(12, 1);
nrf_gpio_pin_write(11, 0);
for (uint16_t ts=0;ts<4000;ts++){}
nrf_gpio_pin_write(11, 1);

}


if (p_evt->params.rx_data.p_data[0]==0xFB)
{ // Reset
m_ctrl=0;
nrf_gpio_pin_write(12, 0);
nrf_gpio_pin_write(11, 0);
for (uint16_t ts=0;ts<4000;ts++){}
nrf_gpio_pin_write(11, 1);

}

Parents Reply Children
  • Hi,

    Please disable NRF_LOG_ENABLED in sdk_config.h to see if that changes anything. The call stack shows that it is processing logs when the fault exception was raised.

  • Hi Vidar,

    now it's jumping the app_error_fault_handler to the NRF_BREAKPOINT_COND

  • Hi,

    So the error is triggered in uart_event_handle, and the error code appears to be NRF_ERROR_DATA_SIZE.

    You can get the exact line number of where the error occurred if you build with the 'DEBUG' flag enabled.

  • Hi Vidar,

    it was triggered by the uart event handler

    void uart_event_handle(app_uart_evt_t * p_event)
    {
        static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
        static uint8_t index = 0;
        uint32_t       err_code;
    
        switch (p_event->evt_type)
        {
            case APP_UART_DATA_READY:
                UNUSED_VARIABLE(app_uart_get(&data_array[index]));
                index++;
    
    							if ((((data_array[index - 2] == '\n') && (data_array[index - 1] == '\r')) ||
    									(index >= m_ble_nus_max_data_len)) || (index>0 && m_ctrl==1))
    								//if(index >0)
    							{
    							 
    								if((index >1) || (index>0 && m_ctrl==1))
    									{
    											//NRF_LOG_DEBUG("Ready to send data over BLE NUS");
    											//NRF_LOG_HEXDUMP_DEBUG(data_array, index);
    
    											do
    											{
    													uint16_t length = ((uint16_t)index);
    													err_code = ble_nus_data_send(&m_nus, data_array, &length, m_conn_handle);
    													if ((err_code != NRF_ERROR_INVALID_STATE) &&
    															(err_code != NRF_ERROR_RESOURCES) &&
    															(err_code != NRF_ERROR_NOT_FOUND))
    													{
    															APP_ERROR_CHECK(err_code);
    													}
    											} while (err_code == NRF_ERROR_RESOURCES);
    									}
    
    									index = 0;
    									
    							}
                break;
    
            case APP_UART_COMMUNICATION_ERROR:
                APP_ERROR_HANDLER(p_event->data.error_communication);
                break;
    
            case APP_UART_FIFO_ERROR:
                APP_ERROR_HANDLER(p_event->data.error_code);
                break;
    
            default:
                break;
        }
    }

    Why this is happening, when I sent from BLE to the device? The UART shouldn't be involved here.

    static void nus_data_handler(ble_nus_evt_t * p_evt)
    {
    
        if (p_evt->type == BLE_NUS_EVT_RX_DATA)
        {
            uint32_t err_code;
    
    //        NRF_LOG_DEBUG("Received data from BLE NUS. Writing data on UART.");
    //        NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
    
            for (uint32_t i = 0; i < p_evt->params.rx_data.length; i++)
            {
                do
                {
                    err_code = app_uart_put(p_evt->params.rx_data.p_data[i]);
                    if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY))
                    {
                        //NRF_LOG_ERROR("Failed receiving NUS message. Error 0x%x. ", err_code);
                        APP_ERROR_CHECK(err_code);
                    }
                } while (err_code == NRF_ERROR_BUSY);
            }
    //        if (p_evt->params.rx_data.p_data[p_evt->params.rx_data.length - 1] == '\r')
    //        {
    //          while (app_uart_put('\n') == NRF_ERROR_BUSY);
    //        }
    					
    				
        }
    		
    		if (p_evt->type == BLE_CTRL)
    		{
    			uint32_t err_code;
    
    			
    			if (p_evt->params.rx_data.p_data[0]==0xFA)	
    			{ // Bootloader Pattern1
    				m_ctrl=1;
    		  	nrf_gpio_pin_write(12, 1);
    				for (uint16_t ts=0;ts<4000;ts++){} 
    				nrf_gpio_pin_write(11, 0);
    				for (uint16_t ts=0;ts<4000;ts++){} 
    				nrf_gpio_pin_write(11, 1);
    			
    			}
    		
    						
    			if (p_evt->params.rx_data.p_data[0]==0xFB)	
    			{ // Reset
    				m_ctrl=0;
    				nrf_gpio_pin_write(12, 0);
    				for (uint16_t ts=0;ts<4000;ts++){} 
    				nrf_gpio_pin_write(11, 0);
    				for (uint16_t ts=0;ts<4000;ts++){} 
    				nrf_gpio_pin_write(11, 1);
    			
    			}
    			
    
    				
    			
    		}
    		
    
    }

    The nrf_gpio_pin_write(12, 1); is raising the uart event handler.

    One important info, from 100 try's 1-2 times works. 

  • Hi,

    Do you see the same if you ignore UART communications errors by commenting the APP_ERROR_HANDLER() line in APP_UART_COMMUNICATION_ERROR?

Related