Hello,
I have two tasks prvTxTask and prvRxTask with the same priority tskIDLE_PRIORITY + 2.
Each 0.5 second prvTxTask send a string to prvRxTask using queue, they work well.
I have one more task vTask_Video_DMA_App with a higher priority than the others have. this task is waiting for semaprore to be released by WriteCallBack function.
The interruptions happens each 33 ms aprox. In the call back function I added a counter in such way the the interruption happens slowly, 1 second aprox.
Below te code in short form
int main( void )
{
if(xTaskCreate( prvTxTask, ( const char * ) "Tx", 2*configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, &xTxTask ) != pdPASS)
{
xil_printf("Tx Task was not created\r\n");
for(;;);
}
if(xTaskCreate( prvRxTask, ( const char * ) "GB", 2*configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, &xRxTask ) != pdPASS)
{
xil_printf("Rx Task was not created\r\n");
for(;;);
}
if( xTaskCreate( vTask_Video_DMA_App, ( const char * ) "VDMA", 10*configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 3, &xHandler_VDMA ) != pdPASS )
{
xil_printf("VDMA Task was not created\r\n");
for(;;);
}
xQueue = xQueueCreate( 4,sizeof( HWstring ) );
configASSERT( xQueue );
vTaskStartScheduler();
for( ;; );
}
static void prvTxTask( void *pvParameters )
{
xil_printf("Tx Task started\r\n");
for( ;; )
{
/* Delay for 1 second. */
vTaskDelay( pdMS_TO_TICKS(500) );
xil_printf("Entering Task Tx\r\n");
if(xQueueSend( xQueue, HWstring, 0L )){
xil_printf("xQueueSend\r\n");
}else{
xil_printf("Tx waiting\r\n");
}
xil_printf("Leaving Task Tx\r\n");
}
}
static void prvRxTask( void *pvParameters )
{
char Recdstring[15] = "";
xil_printf("Rx Task started\r\n");
for( ;; )
{ xil_printf("Entering Task Rx\r\n");
if(xQueueReceive( xQueue, Recdstring, portMAX_DELAY ))
{
xil_printf( "Rx task received string from Tx task\r\n", Recdstring );
}
xil_printf("Leaving Task Rx\r\n");
}
}
void vTask_Video_DMA_App(void *args){
xil_printf("Task VDMA Started\r\n");
SemVDMAWr = xSemaphoreCreateBinary();
if(SemVDMAWr==NULL){
xil_printf("Could not create semaphore SemVDMAWr\n");
return XST_FAILURE;
}
for(;;){
xil_printf("Entering Task VDMA\r\n");
if( xSemaphoreTake( SemVDMAWr, portMAX_DELAY) == pdTRUE ){
xil_printf("VDMA: Semphr took \r\n");
}
xil_printf("Leaving Task VDMA\r\n\n\n");
}
}
static void WriteCallBack(void *CallbackRef, u32 Mask)
{
static BaseType_t xHigherPriorityTaskWoken2 = pdFALSE;
static int counterTx = 0;
xHigherPriorityTaskWoken2 = pdFALSE;
counterTx++;
if(counterTx > 30){
counterTx = 0;
xSemaphoreGiveFromISR(SemVDMAWr, &xHigherPriorityTaskWoken2);
}
portYIELD_FROM_ISR( xHigherPriorityTaskWoken2);
}
As a result , vTask_Video_DMA_App works as it is expected , however , prvTxTask never come out of vtaskDelay() , so nothing is sent to queue , and prvRxTask is always waiting for a message from queue.
It is not supposed that meanwhile prvRxTask and vTask_Video_DMA_App are susppended waiting for their respective triggers, prvTxTask will be ready to run once the time delay passed?
btw, if I set all the tasks with the same priority value , all task start but then they stopped work.
I hope you could tell me what i am missing, or what is the best way make all three task work?
Thanks in advanced
my FreeRTOSConfig.h is :
#ifndef _FREERTOSCONFIG_H
#define _FREERTOSCONFIG_H
#include "xparameters.h"
#include "bspconfig.h"
#define configUSE_PREEMPTION 1
#define configUSE_MUTEXES 1
#define INCLUDE_xSemaphoreGetMutexHolder 1
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_TIMERS 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
#define configUSE_MALLOC_FAILED_HOOK 1
#define configUSE_TRACE_FACILITY 1
#define configUSE_NEWLIB_REENTRANT 0
#define configSTREAM_BUFFER 0
#define configMESSAGE_BUFFER 0
#define configSUPPORT_STATIC_ALLOCATION 0
#define configUSE_16_BIT_TICKS 0
#define configUSE_APPLICATION_TASK_TAG 0
#define configUSE_CO_ROUTINES 0
#define configTICK_RATE_HZ (100)
#define configMAX_PRIORITIES (8)// default : 8
#define configMAX_CO_ROUTINE_PRIORITIES 2
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 200)
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 65536 ) )
#define configMAX_TASK_NAME_LEN 10
#define configIDLE_SHOULD_YIELD 1
#define configUSE_TIME_SLICING 1
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1)
#define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH ((configMINIMAL_STACK_SIZE) * 2)
#define configASSERT( x ) if( ( x ) == 0 ) vApplicationAssert( __FILE__, __LINE__ )
#define configUSE_QUEUE_SETS 1
#define configUSE_TASK_NOTIFICATIONS 1
#define configCHECK_FOR_STACK_OVERFLOW 2
#define configUSE_TASK_FPU_SUPPORT 2
#define configQUEUE_REGISTRY_SIZE 10
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
#define configGENERATE_RUN_TIME_STATS 0
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
#define portGET_RUN_TIME_COUNTER_VALUE()
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#define configUSE_TICKLESS_IDLE 0
#define configTASK_RETURN_ADDRESS prvTaskExitError
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 1
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_eTaskGetState 1
#define INCLUDE_xTimerPendFunctionCall 1
#define INCLUDE_pcTaskGetTaskName 1
#define INCLUDE_xTaskGetHandle 1
#define portPOINTER_SIZE_TYPE uint32_t
#define portTICK_TYPE_IS_ATOMIC 1
#define configMESSAGE_BUFFER_LENGTH_TYPE uint32_t
#define configSTACK_DEPTH_TYPE uint32_t
#define configMAX_API_CALL_INTERRUPT_PRIORITY (18)// default: 18
#define configINTERRUPT_CONTROLLER_BASE_ADDRESS ( XPAR_PS7_SCUGIC_0_DIST_BASEADDR )
#define configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET ( -0xf00 )
#define configUNIQUE_INTERRUPT_PRIORITIES 32
void vApplicationAssert( const char *pcFile, uint32_t ulLine );
void FreeRTOS_SetupTickInterrupt( void );
#define configSETUP_TICK_INTERRUPT() FreeRTOS_SetupTickInterrupt()
void FreeRTOS_ClearTickInterrupt( void );
#define configCLEAR_TICK_INTERRUPT() FreeRTOS_ClearTickInterrupt()
#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetInterruptMask()
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x)
#ifdef FREERTOS_ENABLE_TRACE
#include "FreeRTOSSTMTrace.h"
#endif /* FREERTOS_ENABLE_TRACE */
#endif