[STM32F4] FreeRTOS中STemwin的GUI_Init在启动任务前调用卡死

[复制链接]
6444|10
 楼主| pingis58 发表于 2015-12-31 20:51 | 显示全部楼层 |阅读模式
本帖最后由 pingis58 于 2016-1-4 18:53 编辑

    如题 ,库初始化GUI_Init()调用时,在GUI任务创建后,osKernelStart();启动前,被调用,会使systick中断不触发,但中断配置什么都对,systick计数器也在走,就是不中断。最后卡死在延时那。
BSP初始化代码HAL_Delay()函数中。
    GUI_Init()放在GUI任务运行里面调用,显示及其他运行一切正常,找了好久找不到原因,求解,谢谢大家了
main初始化部分,分三部分代码麻烦分析,main调用,BSP部分,GUI初始化部分
  1. <div class="blockcode"><blockquote>int main(void)
  2. {
  3.   /* STM32F4xx HAL library initialization:
  4.        - Configure the Flash prefetch, instruction and Data caches
  5.        - Configure the Systick to generate an interrupt each 1 msec
  6.        - Set NVIC Group Priority to 4
  7.        - Global MSP (MCU Support Package) initialization
  8.      */
  9.   HAL_Init();  
  10.   
  11.   /* Configure the system clock to 180 MHz */
  12.   SystemClock_Config();
  13.   
  14.         BSP_Config();
  15.   /* Configure LED1 and LED3 */
  16.   BSP_LED_Init(LED1);
  17.   BSP_LED_Init(LED3);
  18.   file_isok = FatFS_Init();
  19.   /* Thread 1 definition */
  20.   osThreadDef(LED1, LED_Thread1, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
  21.   
  22.    /*  Thread 2 definition */
  23.   osThreadDef(LED3, LED_Thread2, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
  24.         osThreadDef(GUI_TASKID, GUI_Thread, osPriorityNormal, 0, 2048);
  25.   
  26.   /* Start thread 1 */
  27.   LEDThread1Handle = osThreadCreate (osThread(LED1), NULL);
  28.   
  29.   /* Start thread 2 */
  30.   LEDThread2Handle = osThreadCreate (osThread(LED3), NULL);
  31.        
  32.         GUIThreadHandle  = osThreadCreate (osThread(GUI_TASKID), NULL);
  33.        
  34.        
  35.   //init_gui();
  36.   
  37.   /* Start scheduler */
  38.   osKernelStart();

  39.   /* We should never get here as control is now taken by the scheduler */
  40.   for(;;);
  41. }
  1. void BSP_Config(void)
  2. {
  3.         /* Initializes the SDRAM device */
  4.   BSP_SDRAM_Init();
  5.   
  6.   /* Initialize the Touch screen */
  7.   BSP_TS_Init(800, 480);
  8.         //BSP_TS_Init(320, 240);
  9.   
  10.   /* Enable the CRC Module */
  11.   __HAL_RCC_CRC_CLK_ENABLE();
  12.         __HAL_RCC_BKPSRAM_CLK_ENABLE();
  13.         /* Compute the prescaler value to have TIM3 counter clock equal to 10 KHz */
  14.   uwPrescalerValue = (uint32_t) ((SystemCoreClock /2) / 10000) - 1;
  15.   
  16.   /* Set TIMx instance */
  17.   TimHandle.Instance = TIM3;
  18.    
  19.   /* Initialize TIM3 peripheral as follows:
  20.        + Period = 500 - 1
  21.        + Prescaler = ((SystemCoreClock/2)/10000) - 1
  22.        + ClockDivision = 0
  23.        + Counter direction = Up
  24.   */
  25.   TimHandle.Init.Period = 500 - 1;
  26.   TimHandle.Init.Prescaler = uwPrescalerValue;
  27.   TimHandle.Init.ClockDivision = 0;
  28.   TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
  29.   if(HAL_TIM_Base_Init(&TimHandle) != HAL_OK)
  30.   {
  31.     while(1)
  32.     {
  33.     }
  34.   }
  35.   
  36.   /*##-2- Start the TIM Base generation in interrupt mode ####################*/
  37.   /* Start Channel1 */
  38.   if(HAL_TIM_Base_Start_IT(&TimHandle) != HAL_OK)
  39.   {
  40.     while(1)
  41.     {
  42.     }
  43.   }
  44. }

GUI的初始化代码
  1. void init_gui(void)
  2. {
  3.         GUI_Init();

  4.   GUI_SetFont(&GUI_Font32_ASCII);

  5.   GUI_DispStringAt("Starting...", 0, 0);
  6.   
  7.   /* Initialize LCD and LEDs */
  8.   GUI_DispStringAt("Initializing lcd...", 0, 32);
  9.   BSP_Config();
  10.   
  11.   GUI_Initialized = 1;
  12.   
  13.   /* Initialize RTC and Backup */
  14.   GUI_DispStringAt("Initializing rtc and backup...", 0, 64);
  15.   RTC_Init();
  16.   
  17.   /* Activate the use of memory device feature */
  18.   WM_SetCreateFlags(WM_CF_MEMDEV);

  19.   /* Do the calibration if needed */
  20.   CALIBRATION_Check();
  21. }
mark0668 发表于 2015-12-31 23:29 | 显示全部楼层
我也试过,没进之前可以中断,进了就不能中断了, 忘了是怎么解决了.
dong_abc 发表于 2016-1-1 08:05 来自手机 | 显示全部楼层
Gui初始化完成之后才能开启系统调度。
天奕 发表于 2016-1-1 19:47 | 显示全部楼层
STemwin时钟开了没
 楼主| pingis58 发表于 2016-1-4 18:48 | 显示全部楼层
mark0668 发表于 2015-12-31 23:29
我也试过,没进之前可以中断,进了就不能中断了, 忘了是怎么解决了.

是的,我问题就这样,没GUI_INIT初始化前,中断是进的。初始化后就不中断了,但定时器还是在跑能看到。
 楼主| pingis58 发表于 2016-1-4 18:50 | 显示全部楼层
dong_abc 发表于 2016-1-1 08:05
Gui初始化完成之后才能开启系统调度。

我的问题是任务启动前,初始化GUI就会使中断不触发了。放在任务启动后就能正常工作。
 楼主| pingis58 发表于 2016-1-4 18:53 | 显示全部楼层
天奕 发表于 2016-1-1 19:47
STemwin时钟开了没

不知道你指的STemwin时钟是哪个。我代码一样,就是把GUI_Init初始化放在任务osKernelStart()后,也就是在任务里面初始化就能正常运行,如果在任务osKernelStart()前,就会使原来已经在systick中断正常的情况下,使中断不会产生。
 楼主| pingis58 发表于 2016-1-4 19:05 | 显示全部楼层
mark0668 发表于 2015-12-31 23:29
我也试过,没进之前可以中断,进了就不能中断了, 忘了是怎么解决了.

也就是这肯定是使用问题,或是某些配置不对导致的吗。我的配置跟官方的demo比对,几乎是一样的,实在找不到原因了。
破阵 发表于 2016-8-6 01:19 来自手机 | 显示全部楼层
您好,我也遇到了同样的问题,现在解决了么
yiyigirl2014 发表于 2018-3-10 09:04 | 显示全部楼层
有没有解决,分享一下经验。
LMCH 发表于 2018-3-12 12:30 | 显示全部楼层
本帖最后由 LMCH 于 2018-3-12 12:32 编辑

单步跟进去看看,CRC开了吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

21

主题

131

帖子

3

粉丝
快速回复 在线客服 返回列表 返回顶部