This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Why osTimerCreate Failed?

I use the Keil MDK for study the CMSIS-RTOS RTX Version 4.74, it is the up to date version. My Development Board is Cortex-M4 STM32F407VG. I use the "Manage the run-time environment" build the project. In the RTX_Conf_CM.C, #define OS_TIMERS 1. But when I run the below program , osTimerCreate returns 0 to id1 and id2. why? Thanks.

#include "cmsis_os.h"

int count = 0;
void Timer1_Callback  (void const *arg){count++;}                   // prototypes for timer callback function
void Timer2_Callback  (void const *arg){count--;}

osTimerDef (Timer1, Timer1_Callback);                      // define timers
osTimerDef (Timer2, Timer2_Callback);

uint32_t  exec1;                                           // argument for the timer call back function
uint32_t  exec2;                                           // argument for the timer call back function
int main (void)  {
  osTimerId id1;                                           // timer id
  osTimerId id2;                                           // timer id

  // Create one-shoot timer
  exec1 = 1;
  id1 = osTimerCreate (osTimer(Timer1), osTimerOnce, &exec1);
  if (id1 != NULL)  {
    // One-shoot timer created
  }

  // Create periodic timer
  exec2 = 2;
  id2 = osTimerCreate (osTimer(Timer2), osTimerPeriodic, &exec2);
  if (id2 != NULL)  {
    // Periodic timer created
  }
}

.