_sched_yield() with systick as _bsp_systimer make task yield forever

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

_sched_yield() with systick as _bsp_systimer make task yield forever

900 Views
gmula
Contributor I

Hello,

I am using IMX1050 EVKB board with MQXv5.

My BSP is setup to use PIT timer as _bsp_systimer (timer that call _time_notify_kernel())

I would like to use the systick timer (systick_devif) as source.

When a switch from PIT to Systick timer, i have quite strange issue :

Task that call  _sched_yield(); are never active again.

for exemple :

while( lwgpio_get_value(&btn1) == LWGPIO_VALUE_LOW  )
{
          // _time_delay(1);   //works fine, task pool btn1
         _sched_yield();      //yield task for ever, do not pool btn1 !
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Here is #define for PIT and SYSTICK Timer :

#define BSP_ALARM_FREQUENCY             (200)
#define BSP_ALARM_RESOLUTION        (1000 / BSP_ALARM_FREQUENCY)

#if 1
#define BSP_SYSTIMER_DEV            systick_devif
#define BSP_SYSTIMER_ID             0
#define BSP_SYSTIMER_SRC_CLK        CM_CLOCK_SOURCE_CORE
#define BSP_SYSTIMER_ISR_PRIOR      2
#define BSP_TIMER_INTERRUPT_VECTOR  INT_SysTick
#else
#define BSP_SYSTIMER_DEV            pit_devif
#define BSP_SYSTIMER_ID             HWTIMER_PIT(1,0)
#define BSP_SYSTIMER_SRC_CLK        CM_CLOCK_SOURCE_PERCLK
#define BSP_SYSTIMER_ISR_PRIOR      2
#define BSP_TIMER_INTERRUPT_VECTOR  INT_PIT
#endif‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Hwtimer init code :

    /* Initialize , set and run system hwtimer */
    result = hwtimer_init(&_bsp_systimer, &BSP_SYSTIMER_DEV, BSP_SYSTIMER_ID, BSP_SYSTIMER_ISR_PRIOR);
    if (MQX_OK != result)
    {
        return result;
    }

    result = hwtimer_set_freq(&_bsp_systimer, BSP_SYSTIMER_SRC_CLK, BSP_ALARM_FREQUENCY);
    if (MQX_OK != result)
    {
        hwtimer_deinit(&_bsp_systimer);
        return result;
    }

    result = hwtimer_callback_reg(&_bsp_systimer,(HWTIMER_CALLBACK_FPTR)_bsp_systimer_callback, NULL);
    if (MQX_OK != result)
    {
        hwtimer_deinit(&_bsp_systimer);
        return result;
    }

    result = hwtimer_start(&_bsp_systimer);
    if (MQX_OK != result)
    {
        hwtimer_deinit(&_bsp_systimer);
        return result;
    }

    /* Initialize the system ticks */
    _time_set_hw_reference(CLOCK_GetPllFreq(kCLOCK_PllArm) / BSP_ALARM_FREQUENCY);
    _time_set_ticks_per_sec(BSP_ALARM_FREQUENCY);
    _time_set_hwticks_per_tick(hwtimer_get_modulo(&_bsp_systimer));
    _time_set_hwtick_function(_bsp_get_hwticks, (void *)NULL);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I have check that _bsp_systimer_callback() is called properly by the hwtimer, and verify the period using a scope:

extern LWGPIO_STRUCT   led1;
void _bsp_systimer_callback(void *dummy)
{
    lwgpio_toggle_value(&led1);
    _time_notify_kernel();
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I both case, i get 100hz witch is what i expect (BSP_ALARM_FREQUENCY             (200))

I have only one task runing (main_task) , the startup task is stop by  _task_block();

const TASK_TEMPLATE_STRUCT  MQX_template_list[] =
{
    /* Task Index,   Function,   Stack,  Priority, Name,     Attributes,          Param, Time Slice */
    { 1,           Startup_task, 1500,   8,      "hello",   MQX_AUTO_START_TASK,    0,     0 },
    { 2,           main_task,  1500,   8,        "Bp",      MQX_AUTO_START_TASK,                      0,     0 },
    { 0 }
};‍‍‍‍‍‍‍‍‍‍‍‍‍‍

When the main task yield, it never become active again (with pit timer as systick source it works well)

what did i miss ?

0 Kudos
1 Reply

768 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Gabriel

I would suggest you contact mqxsales@nxp.com for MQX v5 questions.

Regards

Daniel

0 Kudos