FreeRtos software timer

Former Member
Former Member

Hi friends, I am using STM32CubeMX and trying to start software timer but I couldn't start.These are my codes.Do you have any simple example or How can I manage it?

#include "main.h"
#include "stm32f1xx_hal.h"
#include "cmsis_os.h"


UART_HandleTypeDef huart2;

osThreadId defaultTaskHandle;
osThreadId myTask02Handle;
osTimerId myTimer01Handle;
osTimerId myTimer02Handle;
osTimerId myTimer03Handle;
osTimerId myTimer04Handle;
osMutexId myMutex01Handle;
osSemaphoreId myBinarySem01Handle;

/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART2_UART_Init(void);
void StartDefaultTask(void const * argument);
void StartTask02(void const * argument);
void Callback01(void const * argument);
void Callback02(void const * argument);
extern void Callback03(void const * argument);
extern void Callback04(void const * argument);

int main(void)
{

HAL_Init();
SystemClock_Config();

MX_GPIO_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */

/* USER CODE END 2 */

/* Create the mutex(es) */
/* definition and creation of myMutex01 */
osMutexDef(myMutex01);
myMutex01Handle = osMutexCreate(osMutex(myMutex01));

/* USER CODE BEGIN RTOS_MUTEX */
/* add mutexes, ... */
/* USER CODE END RTOS_MUTEX */

/* Create the semaphores(s) */
/* definition and creation of myBinarySem01 */
osSemaphoreDef(myBinarySem01);
myBinarySem01Handle = osSemaphoreCreate(osSemaphore(myBinarySem01), 1);

/* USER CODE BEGIN RTOS_SEMAPHORES */
/* add semaphores, ... */
/* USER CODE END RTOS_SEMAPHORES */

/* Create the timer(s) */
/* definition and creation of myTimer01 */
osTimerDef(myTimer01, Callback01);
myTimer01Handle = osTimerCreate(osTimer(myTimer01), osTimerOnce, NULL);

/* definition and creation of myTimer02 */
osTimerDef(myTimer02, Callback02);
myTimer02Handle = osTimerCreate(osTimer(myTimer02), osTimerPeriodic, NULL);

/* definition and creation of myTimer03 */
osTimerDef(myTimer03, Callback03);
myTimer03Handle = osTimerCreate(osTimer(myTimer03), osTimerOnce, NULL);

/* definition and creation of myTimer04 */
osTimerDef(myTimer04, Callback04);
myTimer04Handle = osTimerCreate(osTimer(myTimer04), osTimerPeriodic, NULL);

/* USER CODE BEGIN RTOS_TIMERS */
/* start timers, add new ones, ... */
/* USER CODE END RTOS_TIMERS */

/* Create the thread(s) */
/* definition and creation of defaultTask */
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);

/* definition and creation of myTask02 */
osThreadDef(myTask02, StartTask02, osPriorityIdle, 0, 128);
myTask02Handle = osThreadCreate(osThread(myTask02), NULL);

/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */

/* USER CODE BEGIN RTOS_QUEUES */
/* add queues, ... */
/* USER CODE END RTOS_QUEUES */

/* Start scheduler */
osKernelStart();
xTimerStart(myTimer02Handle,1000);
/* We should never get here as control is now taken by the scheduler */

/* Infinite loop */
/* USER CODE BEGIN WHILE */


while (1)
{

}

Parents Reply Children
No data