AnsweredAssumed Answered

SVC with CMSIS-RTOS RTX

Question asked by oscargomezf on Jun 4, 2015
Hi everyone,

I am trying to learn the CMSIS-RTOS RTX. I have experience in FreeRTOS. I am trying to test this example: https://www.keil.com/pack/doc/CMSIS/RTX/html/_example_r_t_x__tutorial.html#RTX_Tutorial_SVC

But my hardware is a STM32F107VC. it's not a
 STM32F429. the test program compiles fine but I can't get the test program work fine: This is my code, Iam using the pin PC13 as interrupt line:

/*----------------------------------------------------------------------------
   CMSIS-RTOS 'main' function template
 *---------------------------------------------------------------------------*/
 
#define osObjectsPublic                     // define objects in main module
#include "osObjects.h"                      // RTOS object definitions
#include "stm32f10x.h"
#include "led_open107v.h"
//#include "joystick_open107v.h"
 
void led_Thread1(void const *argument);
void led_Thread2(void const *argument);
void exti_Thread(void const *argument);
 
void __svc(1) init_EXTI(void);             //Define the EXTI initializing code as a supervisor function
void UserKey_Configuration(void);
void configInterrupt(void);
 
osThreadDef(led_Thread1, osPriorityNormal, 1, 0);
osThreadDef(led_Thread2, osPriorityNormal, 1, 0);
osThreadDef(exti_Thread, osPriorityAboveNormal, 1, 0);
 
osThreadId T_led_ID1;
osThreadId T_led_ID2;   
osThreadId T_exti_ID;
 
void exti_Thread(void const *argument) {
  for (;;) {
    osSignalWait(0x01, osWaitForever);
    LED_On(1);
    osDelay(500);
    LED_Off(1);
  }
}
 
void led_Thread1(void const *argument) {
  for (;;) {
    osSignalWait(0x01, osWaitForever);
    LED_Off(0);
  }
}
 
void led_Thread2(void const *argument) {
  for (;;) {
    LED_On(0);
    osDelay(500);
    osSignalSet(T_led_ID1, 0x01);
    osDelay(500);
  }
}
 
/*
main: initialize and start the system
*/
int main(void) {
  osKernelInitialize();
     init_EXTI(); //initialize the external interrupts
     LED_Initialize();
     
  T_led_ID1 = osThreadCreate(osThread(led_Thread1), NULL);
  T_led_ID2 = osThreadCreate(osThread(led_Thread2), NULL);
  T_exti_ID = osThreadCreate(osThread(exti_Thread), NULL);
  osKernelStart(); // start thread execution                
}
 
void __svc(1) init_EXTI (void);
 
void __SVC_1(void) {
  UserKey_Configuration();
     configInterrupt();
}


/*----------------------------------------------------------------------------
   EXTI interrupt handler
 *---------------------------------------------------------------------------*/
void EXTI15_10_IRQHandler(void) {
     /* Check if EXTI_Line13 is asserted */
     if(EXTI_GetITStatus(EXTI_Line13) != RESET) {
          /* [EXTI15_10_IRQHandler] EXTI_Line13 is asserted. KeyUser PC13 */
          /* We need to clear line pending bit manually */
          osSignalSet(T_exti_ID, 0x01);   
          EXTI_ClearITPendingBit(EXTI_Line13);
     }
}


void UserKey_Configuration(void) {
     GPIO_InitTypeDef GPIO_InitStructure;
  
  /* GPIOC Port Clock Enable */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);                                
 
     /* User key PC13*/
     GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_13;
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
     GPIO_Init(GPIOC, &GPIO_InitStructure);
}
void configInterrupt(void) {
     EXTI_InitTypeDef EXTI_InitStructure;  /* EXTI structure to init EXTI */
  NVIC_InitTypeDef NVIC_InitStructure; /* NVIC structure to init NVIC Controller */
  
     /* keyUser PC13 */
     GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource13); /* Connect EXTI line to button. Port C and pin 13 */
     
     EXTI_InitStructure.EXTI_Line = EXTI_Line13; /* Configure Button port C and pin 13, EXTI line */
     EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; /* Select interrupt mode */
     EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; /* Generate interrupt on rising edge */
     EXTI_InitStructure.EXTI_LineCmd = ENABLE; /* Enable EXTI line */
     EXTI_Init(&EXTI_InitStructure); /* Send values to registers */
     
     /* Configure NVIC */
     NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; /* Select NVIC channel to configure */
     NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; /* Set priority to lowest */
     NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; /* Set subpriority to lowest */
     NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; /* Enable IRQ channel */
     NVIC_Init(&NVIC_InitStructure); /* Update NVIC registers */
     /* End keyuser PC13 */
}

What can I be doing wrong?

Thank you so much, Best regards.


Outcomes