Only single task running and at incorrect frequency on Vorago VA416xx

Hi,
Hopefully someone can help only I have run out of ideas now. I have used FreeRTOS before without issue on ST Arm devices. The VORAGO is a Arm M4 device. At the moment I’m trying to get just a two tasks flashing LEDs at two different rates. I can see in my IAR toolchain that both tasks are created. Task1 should run at 200ms and Task2 at 1000mS. I only see Task2 running and its at 50KHz and not 5Hz. I have trawled the forum and think I covered all the obvious things but still no joy. What else can I check?
My relevant bits of my FreeRTOSConfig is:-

#define configUSE_PREEMPTION        1
#define configUSE_IDLE_HOOK         1
#define configUSE_TICK_HOOK         0
#define configCPU_CLOCK_HZ          ( ( unsigned long ) 50000000 )
#define configTICK_RATE_HZ          ( ( TickType_t ) 1000 )
#define configMAX_PRIORITIES        ( 5 )
#define configMINIMAL_STACK_SIZE    ( ( unsigned short ) 128 )
#define configTOTAL_HEAP_SIZE       ( ( size_t ) ( 20 * 1024 ) )
#define configMAX_TASK_NAME_LEN	    ( 16 )
#define configUSE_TRACE_FACILITY    0
#define configUSE_16_BIT_TICKS      0
#define configIDLE_SHOULD_YIELD     1
#define configUSE_TIME_SLICING      1
//#define configUSE_TASK_NOTIFICATIONS 1
#define configCHECK_FOR_STACK_OVERFLOW 1
#define configUSE_MUTEXES           1

#ifdef __NVIC_PRIO_BITS
	/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
	#define configPRIO_BITS       		__NVIC_PRIO_BITS
#else
	#define configPRIO_BITS       		4        /* 15 priority levels */
#endif

/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY			0x0f

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY	10

/* Interrupt priorities used by the kernel port layer itself.  These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
#define configKERNEL_INTERRUPT_PRIORITY 		( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 	( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

My two simple tasks are:-

void vLED2Code( void * pvParameters )
{
    while(1)
    {
        vTaskDelay(pdMS_TO_TICKS(200));
        portENTER_CRITICAL();
        EVK_LED_PORT->TOGOUT = 1<<EVK_LED2_PIN; // Toggle LED
        portEXIT_CRITICAL();
    }
}

void vLED1Code( void * pvParameters )
{
    while(1)
    {
        vTaskDelay(pdMS_TO_TICKS(1000));
        portENTER_CRITICAL();
        EVK_LED_PORT->TOGOUT = 1<<EVK_LED_PIN; // Toggle LED
        portEXIT_CRITICAL();
    }
}

How do you determine that Task2 is not running?

Is the following value correct according to your CPU clock -

#define configCPU_CLOCK_HZ          ( ( unsigned long ) 50000000 )  

Can you also share code snippets where you create tasks?

Hi,
Task 2 is running and I can see it on a scope. I have also checked xTickCount and that seems to be incrementing. Task 1 is not running. The LEDs does not flash and a breakpoint in the task is not hit.
CPU clock is correct. That was my first thing I checked when I noticed the frequency was wrong.

Task creation snippet

xTaskCreate( vLED1Code, LED1Flasher, configMINIMAL_STACK_SIZE, NULL, 3, NULL);
xTaskCreate( vLED2Code, LED2Flasher, configMINIMAL_STACK_SIZE, NULL, 3, NULL);
vTaskStartScheduler();

I have just noticed my #include “FreeRTOS.h” include in main is highlighted to indicate fatal error not found. Not sure why or if this is related because I have checked the compiler directives and the file locations and presence and there seems no issue. If I add a second instance under it that seems fine. No compile or linker warnings.

Can you check if it is incrementing at the right frequency? This would narrow down if the tick interrupt is firing too fast.

What is the best way to do that? GPIIO toggle within tasks.c? Assuming it is then its toggling at a frequency of 50KHZ.
Max clock rate of chip is 100Mhz. Confident its is running at 50Mhz as that is Vorago supplied clock setup code. That aside does not explain why only 1 task runs.

One q&d way to roughly check the increment frequency if your ide has a real time warch: Pull xTickCount into it and estimate the delta within, say, 2 secs or so.

Your tick count should increase at a rate of 1KHz as per your configuration. 50KHz does not seem correct here. Do you override the vPortSetupTimerInterrupt function - https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/portable/GCC/ARM_CM4F/port.c#L690

I have not modified or are knowingly overriding any functions.
The FreeRTOS code I am using if for the M4F as I dont see any for the M4. Assume this is fine.

The CM3 port is used for Cortex-M4 if floating point support is not needed.
Is the CPU clock setup code (PLLs, dividers etc.) working properly i.e. is the CPU really running at configCPU_CLOCK_HZ ?

I will want FP support later so using M4F. System clock is definitely running at the correct frequency and matches configCPU_CLOCK_HZ .
If I change my system clock to 20Mhz and configCPU_CLOCK_HZ to suit then I get a pulse of 20Khz from my task2LED. If I change to 50MHz then I get 50KHz and if I clock at max processor frequency of 100MHz I get 100KHz.

Its seems that changing configCPU_CLOCK_HZ and / or configTICK_RATE_HZ has no influence on the Task2 LED pulse rate. Only changing my system clock affects it.
So I guess this is also related to why I can only run a single task.
I cant see anything wrong with my setup, file structure or compiler setup. Really relying on you guys now.

Have you checked the return balues of the xTaskCreate() calls? Does task1 ever get to run (bp at its top)?

Task1 never runs or hits a breakpoint. I can see its created as my IAR toolchain shows me crated tasks.

Does your tool chain tell you the task state as well? Is task1 ready?

Also, DO check the return value of every system call. In the field you do not have a debugger, and you do not know what your ide considers a successfully created task

yes it does and its at READY state

So the next thing I would inspect is the priority-ordered ready task list in tasks.c (I do not have the name of the array at hand, sorry, but the code is fairly straightfoward). If both tasks are on the pri3 ready list but task1 never even reaches the beginning of its task fn, there must be something significantly wrong.

You may also for test purposes bump task 1’s priority.