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

Stuck in while loop after event trigger

Hi,

I have a custom board of nrf51822 with no external crystal, neither 16 Mhz nor 32Khz. I am trying to use uart and app timers from SDK11 but when I start any app timer, LFCLK doesn't start. When I force LFCLK to start using NRF_CLOCK->TASKS_LFCLKSTART, the timers get started. Is there any reason behind this?

Also when I try to send using UART, after tx if I wait in a while loop for TX event to complete, even after the event is triggered, the program stays in while loop. Below is the code snippet that I am using:

err_code = nrf_drv_uart_tx((uint8_t*)cmd, strlen(cmd));
APP_ERROR_CHECK(err_code);

while(!tx_done)
{
	__WFE();
}

Here is my uart event handler:

case NRF_DRV_UART_EVT_TX_DONE:
		tx_done = true;
		tx_abort = false;		
                    debug("tx_data is %s\n", (char*)p_event->data.rxtx.p_data);
		break;

Strangely enough if in while loop, I print anything using SEGGER_RTT_printf, everything works as it should, after the event completes program exits from while loop. So my guess was that after the event triggers, the device is going back to sleep, but if I remove __WFE() from the code, the event still triggers but the program remains in while loop. Also when I don't open SEGGER RTT Terminal to print, the code gets stuck in while loop. Please provide suggestion on debugging this issue.

Thanks in advance :)


[EDIT]

Adding the project which is not working. In nrf_drv_config.txt, I replaced APP_IRQ_PRIORITY_LOW to 3, else it won't compile.

For some reason I'm unable to upload file, putting it here

Related