Greetings to all!
There was a problem using FreeRTOS.Using xTaskNotifyIndexedFromISR () in uart_handle, and xTaskNotifyWaitIndexed() in task , a strange switch occursif using portYIELD_FROM_ISR() in uart_handle . Without portYIELD_FROM_ISR() task switching is correct,and if switching task priority =tskIDLE_PRIORITY. Else task one and task two have priority !=skIDLE_PRIORITY using portYIELD_FROM_ISR() task do not swich.
Has anyone else encountered this problem?
For example:
volatile BaseType_t xSendNotificationFromISR ;
TaskHandle_t xTaskToNotify = NULL;
static void led_task(void *pvParameters)
{
reg_gpio_pb_oen &= ~ GPIO_PB7;
while(1)
{
reg_gpio_pb_out |= GPIO_PB7;
vTaskDelay(1000);
reg_gpio_pb_out &= ~GPIO_PB7;
vTaskDelay(1000);
}
(void)(pvParameters);
}
static void led_task1(void *pvParameters)
{
uint32_t ulInterruptStatus;
while(1)
{
xTaskNotifyWaitIndexed( 0, /* Wait for 0th Notificaition */
0x00, /* Don't clear any bits on entry. */
ULONG_MAX, /* Clear all bits on exit. */
&ulInterruptStatus, /* Receives the notification value. */
portMAX_DELAY ); /* Block indefinitely. */
if( ( ulInterruptStatus & 0x01 ) != 0x00 )
{
gpio_toggle(LED_B);
}
}
(void)(pvParameters);
}
int main (void)
{
/.......init..../
xTaskCreate( led_task, "tLed", configMINIMAL_STACK_SIZE, (void*)0, (tskIDLE_PRIORITY+2), 0 );
xTaskCreate( led_task1, "tLed1", configMINIMAL_STACK_SIZE, (void*)0, (tskIDLE_PRIORITY+1), &xTaskToNotify );
vTaskStartScheduler();
return 0;
}
_attribute_ram_code_sec_ void uart1_irq_handler(void)
{
BaseType_t xHigherPriorityTaskWoken;
uint32_t ulStatusRegister=0;
if(uart_get_irq_status(UART_ID,UART_RXDONE))
{
ulStatusRegister|=UART_RX_FLAG_ISR;
xHigherPriorityTaskWoken = pdFALSE;
xTaskNotifyIndexedFromISR( xTaskToNotify, 0, ulStatusRegister, eSetBits, &xHigherPriorityTaskWoken );
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
}
in FreeRTOSConfig.h
#define configUSE_PREEMPTION 1
#define configMAX_PRIORITIES ( 7 )
#define configMINIMAL_STACK_SIZE ( 256 )
#define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_TASK_NOTIFICATIONS 1
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 16 * 1024 ) )
#define configISR_STACK_SIZE_WORDS 64
Using portYIELD_FROM_ISR () led_task1 not running Scheduler does not see threads to execute and spins in IDLE task.
Thanks for your attention.
No related topics |
TLSR9518ADK80D-KIT vs Bluetooth Classic |
hi,
can you try to set led_task1's PRIORITY higher.
Hi, tried from (configMAX_PRIORITIES - 1) to (tskIDLE_PRIORITY),
works only with tskIDLE_PRIORITY.