2015-07-14 4 views
0

J'essaye d'implémenter un petit projet freeRTOS sur Eclipse, en utilisant le plugin gnuarmeclipse et openstm32 et le STM32F411RE. Le projet est en cours de construction et la DEL est connectée à PORT Une broche 5 clignote lorsque le GPIO réglé et les fonctions Reset sont utilisées dans la fonction principale. Mais en utilisant des threads, cela ne fonctionne pas. Ici, j'ajoute du code. Merci pour votre temps précieux.Le thread freertos STM32 ne fonctionne pas

#include "stm32f4xx.h" 
#include "cmsis_os.h" 
#include "stdio.h" 
#include "stm32f4xx_gpio.h" 
#include "stm32f4xx_rcc.h" 


static void StartThread(void const * argument); 
static void SecondThread(void const * argument); 
static void GPIO_Init2(void); 

void Delay2(int); 

#ifdef __GNUC__ 
    #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 
#else 
    #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 
#endif /* __GNUC__ */ 

int main(void) 
{ 

    GPIO_Init2(); 

    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 
    osThreadDef(USER_Thread1, StartThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE); 
    osThreadDef(USER_Thread2, SecondThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE); 
    osThreadCreate (osThread(USER_Thread1), NULL); 
    osThreadCreate (osThread(USER_Thread2), NULL); 

    /* Start scheduler */ 
    osKernelStart(); 
    while (1){ 

    } 

} 
void Delay2(int nCount) 

{ 

while(nCount--){ 
int a=5000; 

while(a--){ 

} 

} 

} 

void GPIO_Init2(void) 
{ 
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA ,ENABLE); 
     GPIO_InitTypeDef GPIO_InitDef; 
     GPIO_InitDef.GPIO_Pin = GPIO_Pin_5; 
     GPIO_InitDef.GPIO_Mode=GPIO_Mode_OUT; 
     GPIO_InitDef.GPIO_OType=GPIO_OType_PP; 
     GPIO_InitDef.GPIO_PuPd=GPIO_PuPd_NOPULL; 
     GPIO_InitDef.GPIO_Speed=GPIO_Speed_50MHz; 
     GPIO_Init(GPIOA, &GPIO_InitDef); 


      GPIO_SetBits(GPIOA,GPIO_Pin_5); 
      osDelay(50); 
      GPIO_ResetBits(GPIOA,GPIO_Pin_5); 
      osDelay(100); 


} 

/* USER CODE BEGIN 4 */ 

/* USER CODE END 4 */ 

/* StartDefaultTask function */ 
static void StartThread(void const * argument) 
{ 
    while(1) { 
     GPIO_SetBits(GPIOA,GPIO_Pin_5); 
     osDelay(500); 
     GPIO_ResetBits(GPIOA,GPIO_Pin_5); 
     osDelay(100); 
     } 

} 

static void SecondThread(void const * argument) 
{ 

     while(1) { 

     } 

} 

#ifdef USE_FULL_ASSERT 

/** 
    * @brief Reports the name of the source file and the source line number 
    * where the assert_param error has occurred. 
    * @param file: pointer to the source file name 
    * @param line: assert_param error line source number 
    * @retval None 
    */ 
void assert_failed(uint8_t* file, uint32_t line) 
{ 
    /* USER CODE BEGIN 6 */ 
    /* User can add his own implementation to report the file name and line number, 
    ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 
    /* USER CODE END 6 */ 

} 

#endif 
+0

osThreadDef, osThreadCreate et osKernelStart ne font pas partie de l'API FreeRTOS. Utilisez-vous vraiment FreeRTOS? Comment comptez-vous que vos deux tâches changent entre les états en cours et bloqués (http://www.freertos.org/RTOS-task-states.html)? Que fait osDelay()? Vos tâches devraient-elles vraiment avoir la même priorité? (Http://www.freertos.org/RTOS-task-priority.html)? Utilisez-vous le temps de tranchage? Est-ce que le noyau RTOS nécessite une source de tick périodique et avez-vous configuré un timer matériel pour fournir ce tick? Il serait probablement préférable de commencer avec l'une des applications de démonstration FreeRTOS. – kkrambo

+0

Merci. J'ai recommencé avec une démo. Mais obtenir erreur « référence non définie à vTaskDelay, xTaskCreate. Je ne peux pas trouver un fichier batch pour STM32F4 pour Eclipse dans le dossier des démos. S'il vous plaît aidez-moi à résoudre ce 1. Création d'un projet STM3F411RE dans Eclipse en utilisant openstm32 plug-in 2. Copier le dossier freeRTOS du projet [link] (https://github.com/henriqueprossi/stm32f4-discovery-freertos) y compris la bibliothèque stip periph 3. supprimer main.c et remplacé par hello_world.c dans l'autre projet. 4. inclus l'en-tête de configuration FreeRTOS stm32f4xx_it.h du même projet – armino

+0

5. inclus rtos inclus le chemin et le chemin CM4 vers le chemin d'accès du compilateur et de l'assembleur 6. Code principal modifié pour supprimer la dépendance sur la bibliothèque de reconnaissance. – armino

Répondre

0

Vous ne pouvez pas utiliser osDelay() en GPIO_Init2() fonction, car le programmateur ne démarre pas encore (osKernelStart()).