I am trying to use the timer object in my code but i can't use it can you help me to use the timer object in my code
/*
* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "blinky_thread.h"
#include "FreeRTOS.h"
#include "timers.h"
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1)
#define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH 128
extern bsp_leds_t g_bsp_leds;
// Global timer handle
TimerHandle_t g_blinky_timer;
// Callback function for the timer
void blinky_timer_callback(TimerHandle_t xTimer)
{
/* LED type structure */
bsp_leds_t leds = g_bsp_leds;
/* If this board has no LEDs then return */
if (0 == leds.led_count)
return;
}
/* Static variable to track pin level */
static bsp_io_level_t pin_level = BSP_IO_LEVEL_LOW;
/* Enable access to the PFS registers */
R_BSP_PinAccessEnable();
/* Update all board LEDs */
for (uint32_t i = 0; i < leds.led_count; i++)
/* Get pin to toggle */
uint32_t pin = leds.p_leds[i];
/* Write to this pin */
R_BSP_PinWrite((bsp_io_port_pin_t) pin, pin_level);
/* Protect PFS registers */
R_BSP_PinAccessDisable();
/* Toggle level for next write */
pin_level = (BSP_IO_LEVEL_LOW == pin_level) ?
BSP_IO_LEVEL_HIGH : BSP_IO_LEVEL_LOW;
void blinky_thread_entry(void * pvParameters)
FSP_PARAMETER_NOT_USED(pvParameters);
/* Check if timer was created successfully */
if (g_blinky_timer == NULL)
/* Handle timer creation failure */
while(1)
/* Trap here if timer creation failed */
/* Start the timer */
if (xTimerStart(g_blinky_timer, 0) != pdPASS)
/* Handle timer start failure */
/* Trap here if timer start failed */
vTaskDelete(NULL);
Hello,
These timers are FreeRTOS software timers and should not be confused with the hardware timers of the MCU. The APIs of those timers are documented at FreeRTOS website:
https://www.freertos.org/Documentation/02-Kernel/04-API-references/11-Software-timers/00-FreeRTOS-Software-Timer-API-Functions
With your current configuration the software timer is one-shot, it will not be auto-reloaded.
Please find an example where a FreeRTOS timer callback is called every 100 ticks.
FreeRTOS_timer.zip
Thank You