本帖最后由 pingis58 于 2016-1-4 18:53 编辑
如题 ,库初始化GUI_Init()调用时,在GUI任务创建后,osKernelStart();启动前,被调用,会使systick中断不触发,但中断配置什么都对,systick计数器也在走,就是不中断。最后卡死在延时那。
BSP初始化代码HAL_Delay()函数中。
GUI_Init()放在GUI任务运行里面调用,显示及其他运行一切正常,找了好久找不到原因,求解,谢谢大家了
main初始化部分,分三部分代码麻烦分析,main调用,BSP部分,GUI初始化部分
- <div class="blockcode"><blockquote>int main(void)
- {
- /* STM32F4xx HAL library initialization:
- - Configure the Flash prefetch, instruction and Data caches
- - Configure the Systick to generate an interrupt each 1 msec
- - Set NVIC Group Priority to 4
- - Global MSP (MCU Support Package) initialization
- */
- HAL_Init();
-
- /* Configure the system clock to 180 MHz */
- SystemClock_Config();
-
- BSP_Config();
- /* Configure LED1 and LED3 */
- BSP_LED_Init(LED1);
- BSP_LED_Init(LED3);
- file_isok = FatFS_Init();
- /* Thread 1 definition */
- osThreadDef(LED1, LED_Thread1, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
-
- /* Thread 2 definition */
- osThreadDef(LED3, LED_Thread2, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
- osThreadDef(GUI_TASKID, GUI_Thread, osPriorityNormal, 0, 2048);
-
- /* Start thread 1 */
- LEDThread1Handle = osThreadCreate (osThread(LED1), NULL);
-
- /* Start thread 2 */
- LEDThread2Handle = osThreadCreate (osThread(LED3), NULL);
-
- GUIThreadHandle = osThreadCreate (osThread(GUI_TASKID), NULL);
-
-
- //init_gui();
-
- /* Start scheduler */
- osKernelStart();
- /* We should never get here as control is now taken by the scheduler */
- for(;;);
- }
- void BSP_Config(void)
- {
- /* Initializes the SDRAM device */
- BSP_SDRAM_Init();
-
- /* Initialize the Touch screen */
- BSP_TS_Init(800, 480);
- //BSP_TS_Init(320, 240);
-
- /* Enable the CRC Module */
- __HAL_RCC_CRC_CLK_ENABLE();
- __HAL_RCC_BKPSRAM_CLK_ENABLE();
- /* Compute the prescaler value to have TIM3 counter clock equal to 10 KHz */
- uwPrescalerValue = (uint32_t) ((SystemCoreClock /2) / 10000) - 1;
-
- /* Set TIMx instance */
- TimHandle.Instance = TIM3;
-
- /* Initialize TIM3 peripheral as follows:
- + Period = 500 - 1
- + Prescaler = ((SystemCoreClock/2)/10000) - 1
- + ClockDivision = 0
- + Counter direction = Up
- */
- TimHandle.Init.Period = 500 - 1;
- TimHandle.Init.Prescaler = uwPrescalerValue;
- TimHandle.Init.ClockDivision = 0;
- TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
- if(HAL_TIM_Base_Init(&TimHandle) != HAL_OK)
- {
- while(1)
- {
- }
- }
-
- /*##-2- Start the TIM Base generation in interrupt mode ####################*/
- /* Start Channel1 */
- if(HAL_TIM_Base_Start_IT(&TimHandle) != HAL_OK)
- {
- while(1)
- {
- }
- }
- }
GUI的初始化代码
- void init_gui(void)
- {
- GUI_Init();
- GUI_SetFont(&GUI_Font32_ASCII);
- GUI_DispStringAt("Starting...", 0, 0);
-
- /* Initialize LCD and LEDs */
- GUI_DispStringAt("Initializing lcd...", 0, 32);
- BSP_Config();
-
- GUI_Initialized = 1;
-
- /* Initialize RTC and Backup */
- GUI_DispStringAt("Initializing rtc and backup...", 0, 64);
- RTC_Init();
-
- /* Activate the use of memory device feature */
- WM_SetCreateFlags(WM_CF_MEMDEV);
- /* Do the calibration if needed */
- CALIBRATION_Check();
- }
|