casan62 wrote on Thursday, August 02, 2018:
Hi,
Using NRF52832 with FreeRTOS v10.0.1
The configASSERT in the callback funtion is asserted and program stops but task has been created successfuly.
I don’t know what is the root cause for this problem as I have another similar callback, task and interrupt priority implemented to TWI that runs fine always.
Can you please give some advice on how to solve this problem ?
Any help is very appreciated.
Thanks.
ISR callback function:
/* The callback interrupt service routine for the UARTE interrupt */
void uarte_interrupt_handler(nrf_drv_uart_event_t * p_event, void* p_context)
{
/* Tracealyzer defitions for tracing ISRs */
traceHandle ISR_UARTE_Handle = xTraceSetISRProperties("ISR_UARTE", 7);
vTraceStoreISRBegin(ISR_UARTE_Handle); /* Tracelyzer ISR tracing */
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
configASSERT(m_uart_task);
/* Notify the task that the p_event occurred in the task's notification value. */
xTaskNotifyFromISR ( m_uart_task, (uint32_t) p_event->type, eSetBits, &xHigherPriorityTaskWoken );
/* switch context is required */
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
vTraceStoreISREnd(xHigherPriorityTaskWoken); /* Stops ISR tracing */
}
Task function:
/* This function gets events from the UART and processes them. */
static void uart_task(void * pvParameter)
{
NRF_LOG_INFO("Enter uart_task.");
uint8_t rxbuffer;
uint32_t err_code;
const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 500 );
BaseType_t xResult;
uint32_t ulNotifiedValue;
if (m_uart_hook != NULL)
{
m_uart_hook(pvParameter);
/* enable receiver */
err_code = nrf_drv_uart_rx(pvParameter, &rxbuffer, 1);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO("UARTE receiver enabled.");
}
while (true)
{
/* Wait to be notified of an interrupt. */
xResult = xTaskNotifyWait(pdFALSE, /* Don't clear bits on entry. */
0xFFFFFFFF, /* Clear all bits on exit. */
&ulNotifiedValue, /* Stores the notified value. */
xMaxBlockTime);
if( xResult == pdPASS )
{
/* A notification was received. See which bits were set. */
if( ( ulNotifiedValue & NRF_DRV_UART_EVT_TX_DONE ) != 0 )
{
/* The TX ISR has set a bit. */
err_code = nrf_drv_uart_tx(pvParameter, &rxbuffer, 1);
APP_ERROR_CHECK(err_code);
}
if( ( ulNotifiedValue & NRF_DRV_UART_EVT_RX_DONE ) != 0 )
{
/* The RX ISR has set a bit. */
if ( nrf_drv_uart_rx_ready(pvParameter) )
{
err_code = nrf_drv_uart_rx(pvParameter, &rxbuffer, 1);
APP_ERROR_CHECK(err_code);
/* echo data to terminal */
err_code = nrf_drv_uart_tx(pvParameter, &rxbuffer, 1);
APP_ERROR_CHECK(err_code);
}
}
if( ( ulNotifiedValue & NRF_DRV_UART_EVT_ERROR ) != 0 )
{
NRF_LOG_INFO("Error in uart comm");
}
}
/* ulTaskNotifyTake(BaseType_t xClearCountOnExit, TickType_t xTicksToWait) allows uart_task to wait in
the Blocked state for its notification value to be greater than zero, and either decrements (subtracts one from)
or clears the task’s notification value before it returns. */
(void) ulTaskNotifyTake(pdTRUE, /* Clear the notification value before exiting (equivalent to the binary semaphore). */
xMaxBlockTime ); /* Block */
}
}
FreeRTOS config:
configLIBRARY_LOWEST_INTERRUPT_PRIORITY 7 // (ARM highest) 0, 1, 2, 3, 4, 5, 6, 7 (ARM lowest)
configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2
configKERNEL_INTERRUPT_PRIORITY configLIBRARY_LOWEST_INTERRUPT_PRIORITY
configMAX_SYSCALL_INTERRUPT_PRIORITY configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY