This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM6442: am6442无法使用定时器自动切换任务,只能手动

Part Number: AM6442

我使用官方提供移植好freertos的工程开发,但是我发现创建多任务的时候无法像之前使用STM32那样会自动利用systick的中断切换任务,

在ClockP_freertos_m4.c里面有如下代码

    /* setup timer but dont start it */
    SysTickTimerP_Params_init(&timerParams);
    timerParams.inputPreScaler    = gClockConfig.timerInputPreScaler;
    timerParams.inputClkHz        = gClockConfig.timerInputClkHz;
    timerParams.periodInUsec      = gClockConfig.usecPerTick;
    timerParams.oneshotMode       = 0;
    timerParams.enableOverflowInt = 1;
    SysTickTimerP_setup(&timerParams);

    /* Get timer reload count, we will use this later to compute current time in usecs */
    gClockCtrl.timerReloadCount = SysTickTimerP_getReloadCount();

    /* setup ISR and enable it */
    HwiP_Params_init(&timerHwiParams);
    timerHwiParams.intNum = gClockConfig.timerHwiIntNum;
    timerHwiParams.callback = ClockP_timerTickIsr;
    timerHwiParams.isPulse = 0;
    HwiP_construct(&gClockCtrl.timerHwiObj, &timerHwiParams);

    /* start the tick timer */
    SysTickTimerP_start();

我的理解是这里已经是定时器的相关配置都做好了,里面有个中断服务函数

void ClockP_timerTickIsr(void *args)
{
    void vPortTimerTickHandler();

    /* increment the systick counter */
    gClockCtrl.ticks++;

    vPortTimerTickHandler();

    ClockP_timerClearOverflowInt(gClockConfig.timerBaseAddr);
}

void vPortTimerTickHandler( void )
{
    if( ulPortSchedularRunning == pdTRUE )
    {
        /* The SysTick runs at the lowest interrupt priority, so when this interrupt
        * executes all interrupts must be unmasked.  There is therefore no need to
        * save and then restore the interrupt mask value as its value is already
        * known. */
        portDISABLE_INTERRUPTS();
        {
            /* Increment the RTOS tick. */
            if( xTaskIncrementTick() != pdFALSE )
            {
                /* A context switch is required.  Context switching is performed in
                * the PendSV interrupt.  Pend the PendSV interrupt. */
                portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
            }
        }
        portENABLE_INTERRUPTS();
    }

每次中断的时候会进入这个中断服务函数里面进行任务切换,但是实际并没有,所以只能手动切换任务,

我尝试自己定义一个定时器,并在这个定时器的中断服务函数里面调用taskYIELD()来切换任务,这个时候也是不能切换任务的。

所以我希望systick中断来切换任务的话该如何做?