Hi,
Trying to get a simple task done …
Can someone point out, what I am doing wrong ?
Thanks,
Manu
xQueueHandle xq;
long task_woken = pdFALSE;
#define TASK_PRIORITY (tskIDLE_PRIORITY)
#define TASK_STACKSIZ configMINIMAL_STACK_SIZE + 50
void tmr_task(void *args)
{
char cp;
#if 0
TickType_t ticks;
const portTickType xFrequency = 50;
ticks = xTaskGetTickCount();
#endif
printf("(%d) %s: Started\r\n", __LINE__, __FUNCTION__);
xq = xQueueCreate(10, sizeof(char));
if (!xq) {
printf("(%d) %s: Queue create Failed!\r\n", __LINE__, __FUNCTION__);
}
printf("(%d) %s: Queue Created\r\n", __LINE__, __FUNCTION__);
LL_TIM_EnableCounter(TIM2); /* enable timer counter */
printf("(%d) %s: Timer Enabled\r\n", __LINE__, __FUNCTION__);
#if 0
while (1) {
xQueueReceiveFromISR(xq, &cp, &task_woken);
printf("%c", cp);
vTaskDelayUntil(&ticks, xFrequency);
}
#endif
while (xQueueReceiveFromISR(xq, &cp, &task_woken))
printf("%c", cp);
if (task_woken != pdFALSE)
taskYIELD();
}
void TIM2_IRQHandler(void)
{
const TickType_t ticks = 500;
char pc = 'H';
if (LL_TIM_IsActiveFlag_UPDATE(TIM2)) {
LL_TIM_ClearFlag_UPDATE(TIM2);
printf("(%d) %s: Send!\r\n",__LINE__, __FUNCTION__);
xQueueSend(xq, &pc, ticks);
}
portEND_SWITCHING_ISR(task_woken);
}
int main(void)
{
SystemClock_Config();
led_init();
config_usart();
printf("\r\n");
printf(" -------------------\r\n");
printf(" STM32H743 TIM2 test\r\n");
printf(" -------------------\r\n");
tim2_init();
xTaskCreate(tmr_task, (const char *) "TMR", TASK_STACKSIZ, NULL, TASK_PRIORITY, NULL);
vTaskStartScheduler();
while (1) { }
}
This is what I receive…
-------------------
STM32H743 TIM2 test
-------------------
(228) tmr_task: Started
(233) tmr_task: Queue Created
(23(260) TIM2_IRQHandler: Send!