cyclic MQX task without using timer

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

cyclic MQX task without using timer

跳至解决方案
541 次查看
gschelotto
Contributor V

Hi,

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

regards,
gaston

1 解答
428 次查看
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 项奖励
回复
2 回复数
429 次查看
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 项奖励
回复
428 次查看
gschelotto
Contributor V

Sol, this is exactly what I needed. Thanks!

regards,
gaston

0 项奖励
回复