Cant get context switching to function

I am running freertos on a dspic33f and am having trouble to get context switching to function properly.
I have verified that the interrupt is happening and that the vTaskIncrementTick() function is being called. I have created 2 different task as follows: xTaskCreate( vIrrigationTask, ( signed char * ) “Irrigation”, 100, NULL, tskIDLE_PRIORITY + 3, NULL );
xTaskCreate( vModuleEmulatorTask, ( signed char * ) “Module”, 100, NULL, tskIDLE_PRIORITY + 2, NULL ); My problem is that which ever task has the highest priority always runs (wont give any time to the other task), or if I set both priorities to be the same (2 for example) then the vModuleEmulatorTask task will only run. I am unsure why this is occurring or what I can do to fix this problem. If you need more information please ask, as I am completely lost and don’t even know what might be useful information to post.

Cant get context switching to function

If you are sure the tic is running, one other possibility is that you haven’t configured the system to be preemptive (in FreeRTOSconfig.h, #define configUSE_PREEMPTION 1)

Cant get context switching to function

Thanks for your reply. I do have configUSE_PREEMPTION set to 1. I am pretty sure that the tick is running. When I place a breakpoint in the vTaskIncrementTick() function, the program gets halted, and it will keep getting re-halted every-time the function is called without the processor resetting. Here is my current configuration settings:
#define configUSE_PREEMPTION            1
#define configUSE_IDLE_HOOK             0  // original value was 1
#define configUSE_TICK_HOOK             0
#define configTICK_RATE_HZ              ( ( portTickType ) 1000 )
#define configCPU_CLOCK_HZ              ( ( unsigned long ) 16000000 )  /* Fosc / 2 */
#define configMAX_PRIORITIES            ( ( unsigned portBASE_TYPE ) 4 )
#define configMINIMAL_STACK_SIZE        ( 115 )
#define configTOTAL_HEAP_SIZE           ( ( size_t ) 5120 )
#define configMAX_TASK_NAME_LEN         ( 16 )
#define configUSE_TRACE_FACILITY        0
#define configUSE_16_BIT_TICKS          1
#define configIDLE_SHOULD_YIELD         1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES       1
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet        1
#define INCLUDE_uxTaskPriorityGet       0
#define INCLUDE_vTaskDelete             0
#define INCLUDE_vTaskCleanUpResources   0
#define INCLUDE_vTaskSuspend            1
#define INCLUDE_vTaskDelayUntil         1
#define INCLUDE_vTaskDelay              1
#define configKERNEL_INTERRUPT_PRIORITY 0x01
Any other ideas?

Cant get context switching to function

Are you sure both tasks are created?  Check the return value of xTaskCreate(). Do you have a malloc failed hook defined?  That could also catch a task not being created. In the case where one task has a higher priority than the other task, the higher priority task should always run as long as it is able to.  For the lower priority task to run the higher priority task must be in the Blocked state (delaying, or blocking on a queue/semaphore, etc.), or Suspended state. Regards.

Cant get context switching to function

I am creating both tasks with a priority of 2 now and am ensuring that they are created properly. The tasks are being created as follows:
    if(xTaskCreate( vIrrigationTask, ( signed char * ) "Irrigation", 100, NULL, tskIDLE_PRIORITY + 2, NULL ) != pdPASS)
    {
        while(1){};
    }
    if(xTaskCreate( vModuleEmulatorTask, ( signed char * ) "Module", 100, NULL, tskIDLE_PRIORITY + 2, NULL ) != pdPASS)
    {
        while(1){};
    }
Only the module task is running when they both have a priority of 2. I created a malloc failed hook, and it is not being called. I also added a delay call to the module task to ensure that it is not blocking. Here is the code (very simple) inside of my module task:
    for( ;; )
    {
        LATGbits.LATG14 = 1; // red led
        vTaskDelay( 100 / portTICK_RATE_MS );
    }