arm - STM32 freertos thread is not working -


i trying implement small freertos project on eclipse, using gnuarmeclipse , openstm32 plugin ans stm32f411re nucleo board. project getting build , led connected port pin 5 blinking when gpio set , reset functions used inside main function. while using threads, not working. here adding code. thank valuable time.

    #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 peripherals, initializes flash interface , 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 name of source file , source line number    * assert_param error has occurred.    * @param file: pointer 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 own implementation report file name , line number,     ex: printf("wrong parameters value: file %s on line %d\r\n", file, line) */   /* user code end 6 */  }  #endif 

you can not use osdelay() in gpio_init2() function because scheduler not started yet (oskernelstart()).


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -