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

Ant Acknowledge message send resets the device

Hi,

I am using a NRF52832 with S212 in a custom board with a host processor. The host processor configures the NRF52 through UART. 

The custom board is configured as slave.The master is an application in a PC with an ANT receiver. The slave and the master are paired at first and then the slave sends some acknowledged data packets to the master.

The problem is sometimes when I instruct the NRF52 to send an acknowledged message through ant_message_send() function, it doesnt send the data but resets the device. Here is the code snippet of the relevant areas. 

void message_request()
{
	uint32_t err_code;
	
	switch(msgID)
	{
		case MESG_ACKNOWLEDGED_DATA_ID:						// Send Acknowledged data
			SEGGER_RTT_WriteString(0, "ACK Request \n");
	    	err_code = ant_message_send(data_send);
			if(err_code == NRF_SUCCESS)
				SEGGER_RTT_WriteString(0, "no error \n");
		    else
				SEGGER_RTT_WriteString(0, "unknown error \n");
		break;

		default:
									
		break;
    }
	memset(data_send,0,ANT_STANDARD_DATA_PAYLOAD_SIZE);
	memset(data_array,0,ANT_STANDARD_DATA_PAYLOAD_SIZE);
}

void uart_reply_send(uint8_t len, uint8_t *data)
{
	char i;
	SEGGER_RTT_WriteString(0, "UART Send \n");
	uint8_t data_tosend[32];
	memcpy(&data_tosend[1],data,len);
	data_tosend[0]=MESG_TX_SYNC;
	if(data != NULL_ptr){
		data_tosend[1]=len-2;
		for(i=0; i<len+1;i++){
			app_uart_put(*(data_tosend+i));
		}
		app_uart_put(endchar);
	}
}

void ant_evt_dispatch(ant_evt_t * p_ant_evt)
{
    //uint32_t err_code;

    if (p_ant_evt->channel == ANT_BROADCAST_CHANNEL_NUMBER)
    {
		ANT_MESSAGE * p_message = (ANT_MESSAGE *) p_ant_evt->msg.evt_buffer;
        
        switch (p_ant_evt->event)
        {
            case EVENT_TRANSFER_TX_FAILED:							
				
					SEGGER_RTT_WriteString(0, "TX Fail \n");
					data_reply[1]=MESG_RESPONSE_EVENT_ID;
					data_reply[3] = MSG_EVT_STD_DATA;
					data_reply[4] = EVENT_TRANSFER_TX_FAILED;
					len=5;
					uart_reply_send(5,data_reply);
            break;
						
			case EVENT_TRANSFER_TX_COMPLETED:
					SEGGER_RTT_WriteString(0, "TX Success \n");
					data_reply[1]=MESG_RESPONSE_EVENT_ID;
					data_reply[3] = MSG_EVT_STD_DATA;
					data_reply[4] = EVENT_TRANSFER_TX_COMPLETED;
					uart_reply_send(5,data_reply);
					len=5;
            break;
            
            default:
                break;
        }
    }
}

If I debug with an RTT Viewer, I can see that as soon as I get "ACK Request", the device is reset. It only happens randomly and once in a while. 

Any insight would be appreciated. 

Parents
  • Hi,

    Sounds to me like you are asserting on an error returned from sd_ant_broadcast_message_tx() or sd_ant_acknowledge_message_tx(). 

    By default when there is an assert the application will reset, this is default behavior done in app_error_fault_handler(). You can define DEBUG (in Preprocessor Symbols) and thereby set a breakpoint in app_error_fault_handler() to find the exact error code, file name, and line number. Likely you can ignore the error code in ant_message_send() instead of calling APP_ERROR_CHECK(err_code);.

    Best regards,
    Kenneth

Reply
  • Hi,

    Sounds to me like you are asserting on an error returned from sd_ant_broadcast_message_tx() or sd_ant_acknowledge_message_tx(). 

    By default when there is an assert the application will reset, this is default behavior done in app_error_fault_handler(). You can define DEBUG (in Preprocessor Symbols) and thereby set a breakpoint in app_error_fault_handler() to find the exact error code, file name, and line number. Likely you can ignore the error code in ant_message_send() instead of calling APP_ERROR_CHECK(err_code);.

    Best regards,
    Kenneth

Children
No Data
Related