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

Running Timesync Example on Sparkfun Breakout

I would like to get the timesync example running on the Sparkfun nRF52832 Breakout board.

I can currently download it to the nRF52832 DK using Segger Studio (after making the changes suggested for the project to work with the Segger IDE) and run it without issues.

I can download other programs onto the Sparkfun board without issues.

I see different results when I debug the DK than when I debug the Sparkfun board. (Assuming the debugging in Segger Studio is actually debugging the Sparkfun board)

The Sparkfun board appears to get stuck in an infinite loop here:

// Skip any string that is pushed to the circular buffer.
while (p_header->base.generic.type == HEADER_TYPE_PUSHED)
{
    rd_idx       += PUSHED_HEADER_SIZE;
    rd_idx       += (p_header->base.pushed.len + p_header->base.pushed.offset);
    p_header = (nrf_log_header_t *)&m_log_data.buffer[rd_idx & mask];
}

which is found in the file nrf_log_frontend.c at function log_skip():

/** 
* @brief Skips the oldest, not pushed logs to make space for new logs.
* @details This function moves forward read index to prepare space for new logs.
*/

static void log_skip(void)
{
	(void)nrf_atomic_flag_set(&m_log_data.log_skipped);
	(void)nrf_atomic_flag_set(&m_log_data.log_skipping);

	uint32_t           rd_idx = m_log_data.rd_idx;
	uint32_t           mask   = m_log_data.mask;
	nrf_log_header_t * p_header = (nrf_log_header_t *)&m_log_data.buffer[rd_idx & mask];
	nrf_log_header_t   header;

	// Skip any string that is pushed to the circular buffer.
	while (p_header->base.generic.type == HEADER_TYPE_PUSHED)
	{
		rd_idx       += PUSHED_HEADER_SIZE;
		rd_idx       += (p_header->base.pushed.len + p_header->base.pushed.offset);
		p_header = (nrf_log_header_t *)&m_log_data.buffer[rd_idx & mask];
	}

	uint32_t i;
	for (i = 0; i < HEADER_SIZE; i++)
	{
		((uint32_t*)&header)[i] = m_log_data.buffer[rd_idx++ & mask];
	}

	switch (header.base.generic.type)
	{
		case HEADER_TYPE_HEXDUMP:
			rd_idx += CEIL_DIV(header.base.hexdump.len, sizeof(uint32_t));
			break;
		case HEADER_TYPE_STD:
			rd_idx += header.base.std.nargs;
			break;
		default:
			ASSERT(false);
			break;
	}

	uint32_t log_skipping_tmp = nrf_atomic_flag_clear_fetch(&m_log_data.log_skipping);
	//update read index only if log_skip was not interrupted by another log skip
	if (log_skipping_tmp)
	{
		m_log_data.rd_idx = rd_idx;
	}
}

Does anyone know what is the issue or of a modification that could be made? Even if it has to remove a portion of the functionality, that's fine.

EDIT:

I now get a hard fault exception regardless if NRF_LOG_ENABLED is set to 0 or 1. The previous infinite loop is no longer happening. I am also using the Segger project that was uploaded to the time sync example GitHub.

Here is a screenshot of the call stack after the exception. My cursor is on the event I assume is the first occurrence of the exception. The same error occurs when running the standard UART example.

image description

You can also see in the debug terminal an ERROR 4 [NRF_ERROR_NO_MEM] goes on to say at line 603 in main. Here is an image of that section of code.

image description

Parents
  • You are right that the RX pin was not being pulled up. I added

    nrf_gpio_cfg_input(RX_PIN_NUMBER, NRF_GPIO_PIN_PULLUP);
    

    after the call to APP_UART_FIFO_INIT() This fixed the issue and I can now connect to the device via Bluetooth, thank you.

    However, I cannot communicate with the Sparkfun board over serial. I can use Termite with the DK for sending messages back and forth. Doing the same method with the Sparkfun board has nothing showing up. Lowering the baud rate and trying flow control didn't change anything.

Reply
  • You are right that the RX pin was not being pulled up. I added

    nrf_gpio_cfg_input(RX_PIN_NUMBER, NRF_GPIO_PIN_PULLUP);
    

    after the call to APP_UART_FIFO_INIT() This fixed the issue and I can now connect to the device via Bluetooth, thank you.

    However, I cannot communicate with the Sparkfun board over serial. I can use Termite with the DK for sending messages back and forth. Doing the same method with the Sparkfun board has nothing showing up. Lowering the baud rate and trying flow control didn't change anything.

Children
No Data
Related