Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

unable to use TASK_NOTIFICATIONS from ISR and configuration of FreeRTOS on Cyclone V.

Posted by ssin on June 12, 2018

I am trying to configure FreeRTOS(V10.0.1)to run on ARM Cortex-A9( on cyclone V's processor 0 ) and using Mentor toolchain' arm-altera-eabi-gcc to compile/link my code.

Followed most of the step as defined at and referred to demo code for Cyclone V : https://www.freertos.org/Using-FreeRTOS-on-Cortex-A-proprietary-interrupt-controller.html

I want to setup an interrupt to run every few ms (say 1ms) and to release sempahore that blocks the task from ISR servicing this interrupt. Want to use task notificaion API to synchronise this ISR and a task. I have set the interrupts priority at (portLOWESTUSABLEINTERRUPTPRIORITY << portPRIORITYSHIFT) (tried with slightly higher priority also)

I have defined ALTINTPROVISIONVECTORSUPPORT in my project so to disable defination of void attribute ((interrupt)) _cs3isrirq(void) in altinterrupt.c and defined a handler like:

void attribute ((interrupt)) _cs3isrirq(void) { FreeRTOSIRQ_Handler(); }

and defined FreeRTOSIRQHandler in FreeRTOSConfig.h as void FreeRTOSIRQHandler ();

Similarly I have defined : void attribute ((interrupt)) _cs3isrswi (void) { FreeRTOSSWI_Handler(); }

I am facing 2 problems:

i) Moment I enable FreeRTOSIRQHandler using above approach, I see software abort and looping in cs3isr_dabort. If I step through, software it does not abort(though task does not releases, see point ii below), but if I press F8 (on DS-5) software immediately goes in abort. Used vApplicationIRQHandler as in the demo project.

ii) The reason I want use portASM.S implementation was I was unable to release the semaphore in the task, it is always stuck in ulTaskNotifyTake(). I cannot see any defination of configKERNELINTERRUPTPRIORITY in the demo supplied, so I have also not defined it. (Even setting it to 255 did not help). I tried binarys semphore (xSemaphoreGiveFromISR/ xSemaphoreTake), but with same result. Saw somewhere it is deprecated so moved to Task notificaion approach.

iii) Also timeout mechansim of ulTaskNotifyTake does not seems to work, though timertick/ timer1 are enabled.

iv)If I don't modify my software to use portASM.s's FreeRTOSIRQHandler and use the one defined in Altera's code software does not abort, but I cannot release the task from sempahore.

What is that I have missed or doing wrong ? Any help will be of great help.

Following is snapshot of ISR code: ... /* At this point xTaskToNotify should not be NULL as a transmission was in progress. */ configASSERT( xTaskToNotify != NULL );

 BaseType_t xHigherPriorityTaskWoken;

/* The xHigherPriorityTaskWoken parameter must be initialized to pdFALSE as
 * it will get set to pdTRUE inside the interrupt safe API function if a
 * context switch is required. */
 xHigherPriorityTaskWoken = pdFALSE;



/* 'Give' the semaphore to unblock the task, passing in the address of xHigherPriorityTaskWoken
 *  as the interrupt safe API function's  pxHigherPriorityTaskWoken parameter. */

 /* Notify the task that the transmission is complete. */
 vTaskNotifyGiveFromISR( xTaskToNotify, &xHigherPriorityTaskWoken );


 portYIELD_FROM_ISR( xHigherPriorityTaskWoken );

... and following of the task:

uint32t testcount = 0; void vTask1( void *pvParameters ) {

 /* As per most tasks, this task is implemented within an infinite loop. */

uint32_t ulNotificationValue = 1;
const TickType_t xMaxBlockTime = pdMS_TO_TICKS(200);

configASSERT( xTaskToNotify == NULL );
xTaskToNotify = xTaskGetCurrentTaskHandle();

ALT_STATUS_CODE status = alt_int_dist_pending_clear(72);
status = alt_int_dist_enable(72);

 for( ;; )
 {
	ulNotificationValue = ulTaskNotifyTake( pdTRUE,
	                                             xMaxBlockTime );

	 if( ulNotificationValue == 1 )
	 {
	        /* The transmission ended as expected. */
		 ALT_PRINTF( "Handler task - Processing event .\r\n" );
	 }
	 else
	 {
	       /* The call to ulTaskNotifyTake() timed out. */
		 ALT_PRINTF( "Handler task - Processing event timeout.\r\n" );
	 }

	 test_count++;


 }

}


unable to use TASK_NOTIFICATIONS from ISR and configuration of FreeRTOS on Cyclone V.

Posted by rtel on June 13, 2018

I suggest starting with the most basic setup, then build from there. A good first place to start would be to disable the tick interrupt (basically never start the tick in the first place), have a single task that does nothing but increment a number then call taskYIELD(). That will check the yield mechanism from a task - the task should basically just increment the number then yield to itself - that is go through the context switch interrupt but just select itself again. To do that make sure the timer task is not started (configUSE_TIMERS is set to 0), and that the single task has a priority greater than the idle priority - that way you are ensured it will always be the task selected to run.

If that works then set configIDLESHOULDYIELD to 1 and lower the priority of the single task you created to 0. Now when you run it the idle task and your single task should just repeatedly yield to each other.

Once that is working you can introduce the tick interrupt and have your single task call vTaskDelay( x ); instead of taskYIELD(). That will test that the tick interrupt is executing correctly, etc and so on until you build up to the yielding from an interrupt scenario you describe. Hopefully you will find the err along the way before you get to the end step.


unable to use TASK_NOTIFICATIONS from ISR and configuration of FreeRTOS on Cyclone V.

Posted by ssin on June 13, 2018

Thanks Richard for quick reply. I have tried as you have suggested, just running 1 task with taskYIED() .(configUSETIMERS , INCLUDExTimerPendFunctionCall and onfigIDLESHOULDYIELD all set to 0 and commented out all the lines in vConfigureTickInterrupt) Created a task like: xTaskCreate( vTask1, "test", 1000, NULL, 1, NULL ); After vTaskStartScheduler() , vTask1 runs . But on second call of taskYIED() it goes all over. Feel some thing wrong from return of FreeRTOSSWIHandler(). Any thoughts on what can be going wrong ?

snapshot of swi handler: void attribute ((interrupt)) _cs3isrswi (void) { FreeRTOSSWI_Handler(); }

that calls portASM.S ( I have not modified any code in this file). FreeRTOSSWIHandler: /* Save the context of the current task and select a new task to run. */ portSAVECONTEXT LDR R0, vTaskSwitchContextConst BLX R0 portRESTORECONTEXT


unable to use TASK_NOTIFICATIONS from ISR and configuration of FreeRTOS on Cyclone V.

Posted by ssin on June 13, 2018

Thanks Richard for quick reply. I have tried as you have suggested, just running 1 task with taskYIELD() .(configUSETIMERS , INCLUDExTimerPendFunctionCall and onfigIDLESHOULDYIELD all set to 0 and commented out all the lines in vConfigureTickInterrupt) Created a task like: xTaskCreate( vTask1, "test", 1000, NULL, 1, NULL ); After vTaskStartScheduler() , vTask1 runs . But on second call of taskYIELD() it goes all over. Feel some thing wrong from return of FreeRTOSSWIHandler(). Any thoughts on what can be going wrong ?

snapshot of swi handler: void attribute ((interrupt)) _cs3isrswi (void) { FreeRTOSSWI_Handler(); }

that calls portASM.S ( I have not modified any code in this file). FreeRTOSSWIHandler: /* Save the context of the current task and select a new task to run. */ portSAVECONTEXT LDR R0, vTaskSwitchContextConst BLX R0 portRESTORECONTEXT


unable to use TASK_NOTIFICATIONS from ISR and configuration of FreeRTOS on Cyclone V.

Posted by edwards3 on June 13, 2018

Can you copy the interrupt functions in the Cyclone example in the download https://www.freertos.org/RTOSAlteraSoCARMCortex-A9.html


unable to use TASK_NOTIFICATIONS from ISR and configuration of FreeRTOS on Cyclone V.

Posted by ssin on June 13, 2018

Thanks for quick reply Edwards. In demo it is done in linker setting --defsym=cs3isrswi=FreeRTOSSWIHandler, need to find equivalent setting for Mentor toolchain' arm-altera-eabi-gcc . --defsym is not recoginised by this toolchain.


unable to use TASK_NOTIFICATIONS from ISR and configuration of FreeRTOS on Cyclone V.

Posted by ssin on June 13, 2018

Thanks for quick reply Edwards. In demo it is done in linker setting --defsym=cs3isrswi=FreeRTOSSWIHandler, need to find equivalent setting for Mentor toolchain' arm-altera-eabi-gcc . --defsym is not recoginised by this toolchain.


unable to use TASK_NOTIFICATIONS from ISR and configuration of FreeRTOS on Cyclone V.

Posted by ssin on June 13, 2018

Setting in xlinker option as --defsym=cs3isrswi=FreeRTOSSWIHandler solved the problem. I can test one task as richard had suggested. Will test remaining and update. Thanks once again.


unable to use TASK_NOTIFICATIONS from ISR and configuration of FreeRTOS on Cyclone V.

Posted by ssin on June 14, 2018

All options suggested by Richard works. Also task notification from ISR works fine.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.1 is available for immediate download. MIT licensed, includes 64-bit RISC-V, NXP Cortex-M33 demo & Nuvoton Cortex-M23 demo.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Mediatek

Renesas

RISC-V

SiFIve RISC-V

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner