cyclic MQX task without using timer

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

cyclic MQX task without using timer

Jump to solution
460 Views
gschelotto
Contributor V

Hi,

How can I implement a repetitive MQX task (i.e. every 1s) without using _timer components?

regards,
gaston

1 Solution
347 Views
soledad
NXP Employee
NXP Employee

Hi Gaston,

I need a little more information about your application however an option is to have into a task an infinite loop with a _time_delay(xxx). Please check the below example, this task toggle the pin value every second.

 

void led3_task(uint32_t initial_data)

{

int value = 0;

LWGPIO_STRUCT led3;

printf("\n led3 task \n");

lwgpio_init(&led3, BSP_LED3, LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_NOCHANGE)) ;

lwgpio_set_functionality(&led3, BSP_LED3_MUX_GPIO);

while (TRUE)

{

_time_delay(1000);

lwgpio_set_value(&led3, value); /* toggle pin value */

value = value^1;

}

}


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
2 Replies
348 Views
soledad
NXP Employee
NXP Employee

Hi Gaston,

I need a little more information about your application however an option is to have into a task an infinite loop with a _time_delay(xxx). Please check the below example, this task toggle the pin value every second.

 

void led3_task(uint32_t initial_data)

{

int value = 0;

LWGPIO_STRUCT led3;

printf("\n led3 task \n");

lwgpio_init(&led3, BSP_LED3, LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_NOCHANGE)) ;

lwgpio_set_functionality(&led3, BSP_LED3_MUX_GPIO);

while (TRUE)

{

_time_delay(1000);

lwgpio_set_value(&led3, value); /* toggle pin value */

value = value^1;

}

}


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
347 Views
gschelotto
Contributor V

Sol, this is exactly what I needed. Thanks!

regards,
gaston

0 Kudos