All, I created a simple program to start a virtual timer object in CMSIS OS2. After succesfully creating the periodic timer, I can't start the timer. The return code is: 0xFFFFFFFD osErrorResource. I use Keil uVision5 and an NXP LPC1768 processor
Following is my code:
#include <RTE_Components.h> #include CMSIS_device_header #include <cmsis_os2.h> /* ARM::CMSIS:RTOS:Keil RTX5 */ #include "LED.h" static void Callback (void *argument); /* Function prototype Call back function */ static uint32_t timerDelay; /* Holds timer value */ /*---------------------------------------------------------------------------- * Main Entry point, execution starts here *---------------------------------------------------------------------------*/ int main (void) { osTimerId_t periodic_id; /* Thread handle */ osStatus_t status; /* Function return status */ SystemCoreClockUpdate(); /* Evaluate clock register settings and calculate current core clock */ LED_Initialize (); /* Initialize LEDs */ osKernelInitialize (); /* Initialize CMSIS-RTOS2 */ periodic_id = osTimerNew (Callback, osTimerPeriodic, (void *)5, NULL); /* Create a periodic timer, */ /* (void*)5 is passed as argument to the callback function */ if (periodic_id != NULL) { timerDelay = 1000; /* Number of Time Ticks */ status = osTimerStart (periodic_id, timerDelay); /* Start timer */ if (status != osOK) { /* Error: Timer could not be started */ status = osTimerStop (periodic_id); /* Stop timer */ } } osKernelStart(); /* Start thread execution */ } void Callback (void *argument) { int32_t arg = (int32_t)argument; /* cast back argument '5' */ LED_Flash (); }
In RTXConfig.h, I defined 5 User Threads with 'Object Specific Memory Allocation' and 2 Timer Objects (priority 'High') also with 'Object Specific Memory Allocation'. The default 'Thread Stack size' and the 'Timer Thread Stach size' both are 200 bytes.
Does anyone have an idea what might cause this error?
Robert, thanks. That worked out well. The timer now starts.