硬汉嵌入式论坛

 找回密码
 立即注册
查看: 3528|回复: 20
收起左侧

[FreeRTOS] FreeRTOS STemWin5.32  移植

[复制链接]

10

主题

38

回帖

68

积分

初级会员

积分
68
发表于 2017-8-11 12:07:17 | 显示全部楼层 |阅读模式
在 freertos 上移植 STemWinLibrary532 提示下面的消息:
  1. Error[Li005]: no definition for "osMutexRelease" [referenced from D:\STM32_CODE\FreeRTOS\project_FreeRTOS_STewin\Project\Flash\Obj\GUI_X_OS.o]
  2. Error[Li005]: no definition for "osMutexWait" [referenced from D:\STM32_CODE\FreeRTOS\project_FreeRTOS_STewin\Project\Flash\Obj\GUI_X_OS.o]
  3. Error[Li005]: no definition for "osThreadGetId" [referenced from D:\STM32_CODE\FreeRTOS\project_FreeRTOS_STewin\Project\Flash\Obj\GUI_X_OS.o]
  4. Error[Li005]: no definition for "osMutexCreate" [referenced from D:\STM32_CODE\FreeRTOS\project_FreeRTOS_STewin\Project\Flash\Obj\GUI_X_OS.o]
  5. Error[Li005]: no definition for "osSemaphoreCreate" [referenced from D:\STM32_CODE\FreeRTOS\project_FreeRTOS_STewin\Project\Flash\Obj\GUI_X_OS.o]
  6. Error while running Linker
复制代码
这几个函数是要自己实现吗 ?
微信截图_20170811120114.png
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107027
QQ
发表于 2017-8-11 12:26:58 | 显示全部楼层
从你的代码来看,是用的加了封装层CMSIS-RTOS的FreeRTOS。具体这个封装层,我基本没有用过。

根据你的提示,这个是因为你没有开启互斥信号量等功能,需要你开启下,你看看你的CMSIS-RTOS FreeRTOS里面怎么开启。无封装层的FreeRTOS,仅需在FreeRTOSConfig.h文件开启即可。
回复

使用道具 举报

10

主题

38

回帖

68

积分

初级会员

积分
68
 楼主| 发表于 2017-8-11 12:48:53 | 显示全部楼层
HI  
   请问 CMSIS\\RTOS\\Template\\cmsis_os.h 是这个文件吗 ? 有移植的教程吗 ?
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107027
QQ
发表于 2017-8-11 13:57:06 | 显示全部楼层

回 wendell.li 的帖子

wendell.li:HI  
   请问 CMSIS\\RTOS\\Template\\cmsis_os.h 是这个文件吗 ? 有移植的教程吗 ? (2017-08-11 12:48) 
CMSIS-RTOS的封装层暂时还没有精力去搞,原始FreeRTOS的操作直接这里下载例子或者教程即可:http://www.armbbs.cn/forum.php?mod=viewthread&tid=17658

需要CMSIS-RTOS FreeRTOS的例子直接现在ST官方的HAL,里面有官方各种探索版的例子,都是加上封装层的,研究对比下即可。
回复

使用道具 举报

10

主题

38

回帖

68

积分

初级会员

积分
68
 楼主| 发表于 2017-8-11 15:16:48 | 显示全部楼层
这个适配的时候,是需要把自己实现的画点划线函数填充进去吗 ? 在那个接口中适配呢 ?
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107027
QQ
发表于 2017-8-11 15:34:26 | 显示全部楼层

回 wendell.li 的帖子

wendell.li:这个适配的时候,是需要把自己实现的画点划线函数填充进去吗 ? 在那个接口中适配呢 ? (2017-08-11 15:16)
你楼主位的问题,跟emWin的LCD接口函数没有关系,你这里是因为文件GUI_X_OS.c文件里面调用CMSIS-RTOS FreeRTOS的API函数了,所以需要你使能FreeRTOS的相关配置。
回复

使用道具 举报

10

主题

38

回帖

68

积分

初级会员

积分
68
 楼主| 发表于 2017-8-11 15:43:02 | 显示全部楼层

回 eric2013 的帖子

eric2013:你楼主位的问题,跟emWin的LCD接口函数没有关系,你这里是因为文件GUI_X_OS.c文件里面调用CMSIS-RTOS FreeRTOS的API函数了,所以需要你使能FreeRTOS的相关配置。
 (2017-08-11 15:34) 
这个问题我通过使用下载的官方包里面的GUI_X_FreeRTOS.c 就能编译通过了。我现在就好奇怎么把操作 LCD 的接口适配上去。
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107027
QQ
发表于 2017-8-11 15:58:45 | 显示全部楼层

回 wendell.li 的帖子

wendell.li:这个问题我通过使用下载的官方包里面的GUI_X_FreeRTOS.c 就能编译通过了。我现在就好奇怎么把操作 LCD 的接口适配上去。 (2017-08-11 15:43) 
看我们的教程就行了,这就很简单了:http://www.armbbs.cn/forum.php?mod=viewthread&tid=2932

哪里不理解找我。
回复

使用道具 举报

10

主题

38

回帖

68

积分

初级会员

积分
68
 楼主| 发表于 2017-8-14 10:32:32 | 显示全部楼层
奇怪的是我移植完成

      GUI_SetBkColor(GUI_BLUE);
      GUI_SetColor(GUI_YELLOW);
     // GUI_Clear();
      GUI_SetFont(&GUI_Font8x16);
      GUI_DispString("www.armfly.com \\navailable");

卡在 GUI_Clear 函数,卡住不动
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107027
QQ
发表于 2017-8-14 12:07:27 | 显示全部楼层

回 wendell.li 的帖子

wendell.li:奇怪的是我移植完成

      GUI_SetBkColor(GUI_BLUE);
      GUI_SetColor(GUI_YELLOW);
     // GUI_Clear();
....... (2017-08-14 10:32) 
移植的有问题,继续检测。
回复

使用道具 举报

10

主题

38

回帖

68

积分

初级会员

积分
68
 楼主| 发表于 2017-8-15 10:32:25 | 显示全部楼层
我测试了一下,在 freertos 任务创建之前调用能够正常显示和使用,但是在任务中调用就会导致挂死。
如下调用正常显示
  1. __set_PRIMASK(1);
  2.   Bsp_Init();
  3.   printf("***********************************\\r\\n");
  4.   GUI_Init();
  5.   GUI_SetBkColor(GUI_BLUE);
  6.   GUI_SetColor(GUI_RED);
  7.   GUI_Clear();
  8.   GUI_SetFont(&GUI_Font8x18);
  9.   GUI_DispString("test test test test");
  10.       
  11.   printf("aaaaaaaaaaaaaaa\\r\\n");
  12.   AppTaskCreate();
  13.   vTaskStartScheduler();
  14.   while(1);
复制代码
但是在创建的任务中调用就会挂死系统:
  1. GUI_DispString("www.armfly.com \\navailable");
  2.     while(1)
  3.     {
  4.       printf("我在执行,我是任务 vTaskLED3 \\r\\n");
  5.       GUI_Delay(10);
  6.       //Bsp_LEDToggle(LED3);
  7.       //vTaskDelay(400);
  8.     }
复制代码
这个情况可能是啥原因呢 ?
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107027
QQ
发表于 2017-8-15 10:35:27 | 显示全部楼层

回 wendell.li 的帖子

wendell.li:我测试了一下,在 freertos 任务创建之前调用能够正常显示和使用,但是在任务中调用就会导致挂死。
如下调用正常显示
__set_PRIMASK(1);
  Bsp_Init();
  printf("***********************************\\r\\n");
....... (2017-08-15 10:32)
加大任务栈试试。
回复

使用道具 举报

10

主题

38

回帖

68

积分

初级会员

积分
68
 楼主| 发表于 2017-8-15 13:01:49 | 显示全部楼层
我尝试了增加堆栈也不行,如下是我的配置和代码请帮忙检查一下,可能有点多,谢谢了!
  1. /*****************************************************************************
  2. *
  3. *    模块名称 : 主函数
  4. *    文件名称 : main.c
  5. *    版    本 : V1.0
  6. *    说    明 : 主函数文件
  7. *
  8. *    修改记录 :
  9. *        版本号  日期        作者     说明
  10. *        V1.0    2017-07-18 wendell  正式发布
  11. *
  12. *
  13. ******************************************************************************/
  14. #include "stm32f103_main.h"
  15. static void vTaskLED1(void *pvParameters);
  16. static void vTaskLED2(void *pvParameters);
  17. static void vTaskLED3(void *pvParameters);
  18. static void AppTaskCreate (void);
  19. void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName);
  20. static TaskHandle_t xHandleTaskLED1 = NULL;
  21. static TaskHandle_t xHandleTaskLED2 = NULL;
  22. static TaskHandle_t xHandleTaskLED3 = NULL;
  23. /*******************************************************************************
  24. *    函 数 名: vTaskLED1
  25. *    功能说明: 任务1
  26. *    形    参:  无
  27. *    返 回 值: 无
  28. *******************************************************************************/
  29. static void vTaskLED1(void *pvParameters)
  30. {
  31.     while(1)
  32.     {
  33.       printf("我在执行,我是任务 vTaskLED1 \\r\\n");
  34.       Bsp_LEDToggle(LED1);
  35.       vTaskDelay(800);
  36.     }
  37. }
  38. /*******************************************************************************
  39. *    函 数 名: vTaskLED2
  40. *    功能说明: 任务2
  41. *    形    参:  无
  42. *    返 回 值: 无
  43. *******************************************************************************/
  44. static void vTaskLED2(void *pvParameters)
  45. {
  46.     while(1)
  47.     {
  48.       printf("我在执行,我是任务 vTaskLED2 \\r\\n");
  49.       Bsp_LEDToggle(LED2);
  50.       vTaskDelay(200);
  51.     }
  52. }
  53. /*******************************************************************************
  54. *    函 数 名: vTaskLED3
  55. *    功能说明: 任务3
  56. *    形    参:  无
  57. *    返 回 值: 无
  58. *******************************************************************************/
  59. static void vTaskLED3(void *pvParameters)
  60. {
  61.     GUI_DispString("www.armfly.com \\navailable");
  62.     while(1)
  63.     {
  64.       printf("我在执行,我是任务 vTaskLED3 \\r\\n");
  65.       GUI_Delay(10);
  66.       //Bsp_LEDToggle(LED3);
  67.       //vTaskDelay(400);
  68.     }
  69. }
  70. /*******************************************************************************
  71. *    函 数 名: AppTaskCreate
  72. *    功能说明: 创建任务
  73. *    形    参:  无
  74. *    返 回 值: 无
  75. *******************************************************************************/
  76. static void AppTaskCreate (void)
  77. {
  78.   //任务函数  任务名称 栈大小 任务参数 优先级  任务句柄
  79.   xTaskCreate( vTaskLED1,"vTaskLED1",512, NULL, 5,&xHandleTaskLED1);
  80.   xTaskCreate( vTaskLED2,"vTaskLED2",512, NULL, 3,&xHandleTaskLED2);
  81.   xTaskCreate( vTaskLED3,"vTaskLED3",2048, NULL, 2,&xHandleTaskLED3);
  82. }
  83. /*
  84. *********************************************************************************************************
  85. *  函 数 名: vApplicationStackOverflowHook
  86. *  功能说明: 栈溢出的钩子函数
  87. *  形 参: xTask 任务句柄
  88. * pcTaskName 任务名
  89. *  返 回 值: 无
  90. *********************************************************************************************************
  91. */
  92. void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName )
  93. {
  94.   printf("task: %s stack error \\r\\n", pcTaskName);
  95. }
  96. int main(void)
  97. {
  98.   //为了防止初始化 STM32 外设时有中断服务程序执行,这里禁止全局中断(除了 NMI 和 HardFault)
  99.   __set_PRIMASK(1);
  100.   Bsp_Init();
  101.   printf("***********************************\\r\\n");
  102.   GUI_Init();
  103.   GUI_SetBkColor(GUI_BLUE);
  104.   GUI_SetColor(GUI_RED);
  105.   GUI_Clear();
  106.   GUI_SetFont(&GUI_Font8x18);
  107.   GUI_DispString("test test test test");
  108.       
  109.   printf("aaaaaaaaaaaaaaa\\r\\n");
  110.   AppTaskCreate();
  111.   vTaskStartScheduler();
  112.   while(1);
  113. }
复制代码
  1. /******************************************************************************
  2.                               已经设置项
  3. ******************************************************************************/
  4. //确保是被编译器使用,不是被汇编文件所使用
  5. #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
  6. #include <stdint.h>
  7. extern volatile uint32_t ulHighFrequencyTimerTicks;
  8. #endif
  9. //内核调度方式 1 抢占式  0  合作式调度
  10. #define configUSE_PREEMPTION        1
  11. //配置用于使能 tickless 低功耗模式  1 使能 0 禁止
  12. #define configUSE_TICKLESS_IDLE     0
  13. //禁止空闲任务钩子函数
  14. #define configUSE_IDLE_HOOK            0
  15. //禁能滴答定时器中断里面执行的钩子函数
  16. #define configUSE_TICK_HOOK            0
  17. //CPU 主频
  18. #define configCPU_CLOCK_HZ            ( ( unsigned long ) 72000000 )   
  19. //系统节拍数
  20. #define configTICK_RATE_HZ            ( ( TickType_t ) 1000 )
  21. //用户最大任务数,实际使用时为 0 - (configMAX_PRIORITIES- 1 )
  22. #define configMAX_PRIORITIES        ( 6 )
  23. //参数用于定义空闲任务的栈空间大小,单位字,即 4 字节
  24. #define configMINIMAL_STACK_SIZE    ( ( unsigned short ) 1024 )
  25. //定义堆大小,FreeRTOS 内核,用户动态内存申请,任务栈,任务创建,信号量创建,
  26. //消息队列创建等都需要用这个空间
  27. #define configTOTAL_HEAP_SIZE        ( ( size_t ) ( 17 * 1024 ) )
  28. //任务名的长度 末尾的结束符 '\\0'也要计算在内
  29. #define configMAX_TASK_NAME_LEN        ( 16 )
  30. //使能此配置将添加额外的结构体成员和函数,以此来协助可视化和跟踪,在使用
  31. //IAR 中的 FreeRTOS插件时要使能这个配置,否则无法显示任务栈的使用情况
  32. #define configUSE_TRACE_FACILITY    1
  33. //事件标志的个数  0 为 32bit 的 低 24bit
  34. #define configUSE_16_BIT_TICKS        0
  35. //使能与空闲任务同优先级的任务  使能抢占式调度器 且创建与空闲任务同优先级的任务
  36. #define configIDLE_SHOULD_YIELD        1
  37. /* Co-routine definitions. */
  38. //使能合作式调度相关函数
  39. #define configUSE_CO_ROUTINES         0
  40. //此参数用于定义可供用户使用的最大的合作式任务优先级数,如果这个定义的是 5,
  41. //那么用户可以使用的优先级号是 0,1,2,3,4,不包含 5,
  42. #define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
  43. //使能计数信号量
  44. #define configUSE_COUNTING_SEMAPHORES         1
  45. //使能互斥信号量
  46. #define configUSE_MUTEXES 1
  47. //使能任务间直接的消息传递,包含信号量,事件标志组和消息邮箱
  48. #define configUSE_TASK_NOTIFICATIONS    1  
  49. /******************************************************************************
  50.                           查看任务状态配置
  51. ******************************************************************************/
  52. #define configGENERATE_RUN_TIME_STATS               1
  53. #define configUSE_TRACE_FACILITY                    1
  54. #define configUSE_STATS_FORMATTING_FUNCTIONS        1
  55. #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()     (ulHighFrequencyTimerTicks = 0ul)
  56. #define portGET_RUN_TIME_COUNTER_VALUE()    ulHighFrequencyTimerTicks
复制代码
GUI_X_FreeRTOS.c
  1. /*********************************************************************
  2. *          Portions COPYRIGHT 2016 STMicroelectronics                *
  3. *          Portions SEGGER Microcontroller GmbH & Co. KG             *
  4. *        Solutions for real time microcontroller applications        *
  5. **********************************************************************
  6. *                                                                    *
  7. *        (c) 1996 - 2015  SEGGER Microcontroller GmbH & Co. KG       *
  8. *                                                                    *
  9. *        Internet: www.segger.com    Support:  support@segger.com    *
  10. *                                                                    *
  11. **********************************************************************
  12. ** emWin V5.32 - Graphical user interface for embedded applications **
  13. All  Intellectual Property rights  in the Software belongs to  SEGGER.
  14. emWin is protected by  international copyright laws.  Knowledge of the
  15. source code may not be used to write a similar product.  This file may
  16. only be used in accordance with the following terms:
  17. The  software has  been licensed  to STMicroelectronics International
  18. N.V. a Dutch company with a Swiss branch and its headquarters in Plan-
  19. les-Ouates, Geneva, 39 Chemin du Champ des Filles, Switzerland for the
  20. purposes of creating libraries for ARM Cortex-M-based 32-bit microcon_
  21. troller products commercialized by Licensee only, sublicensed and dis_
  22. tributed under the terms and conditions of the End User License Agree_
  23. ment supplied by STMicroelectronics International N.V.
  24. Full source code is available at: www.segger.com
  25. We appreciate your understanding and fairness.
  26. ----------------------------------------------------------------------
  27. File        : GUI_X.C
  28. Purpose     : This file provides emWin Interface with FreeRTOS
  29. ---------------------------END-OF-HEADER------------------------------
  30. */
  31. /**
  32.   ******************************************************************************
  33.   * @attention
  34.   *
  35.   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  36.   * You may not use this file except in compliance with the License.
  37.   * You may obtain a copy of the License at:
  38.   *
  39.   *        http://www.st.com/software_license_agreement_liberty_v2
  40.   *
  41.   * Unless required by applicable law or agreed to in writing, software
  42.   * distributed under the License is distributed on an "AS IS" BASIS,
  43.   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  44.   * See the License for the specific language governing permissions and
  45.   * limitations under the License.
  46.   *
  47.   ******************************************************************************
  48.   */
  49. /* Includes ------------------------------------------------------------------*/
  50. #include "GUI.h"
  51.    
  52.     /* FreeRTOS include files */
  53. #include "FreeRTOS.h"
  54. #include "task.h"
  55. #include "timers.h"
  56. #include "semphr.h"
  57.    
  58. /*********************************************************************
  59. *
  60. * Global data
  61. */
  62. static xSemaphoreHandle xQueueMutex;
  63. static xSemaphoreHandle xSemaTxDone;
  64. /*********************************************************************
  65. *
  66. * Timing:
  67. * GUI_X_GetTime()
  68. * GUI_X_Delay(int)
  69. Some timing dependent routines require a GetTime
  70. and delay function. Default time unit (tick), normally is
  71. 1 ms.
  72. */
  73. int GUI_X_GetTime(void)
  74. {
  75.   return ((int) xTaskGetTickCount());
  76. }
  77. void GUI_X_Delay(int ms)
  78. {
  79.   vTaskDelay( ms );
  80. }
  81. /*********************************************************************
  82. *
  83. * GUI_X_Init()
  84. *
  85. * Note:
  86. * GUI_X_Init() is called from GUI_Init is a possibility to init
  87. * some hardware which needs to be up and running before the GUI.
  88. * If not required, leave this routine blank.
  89. */
  90. void GUI_X_Init(void) {
  91. }
  92. /*********************************************************************
  93. *
  94. * GUI_X_ExecIdle
  95. *
  96. * Note:
  97. * Called if WM is in idle state
  98. */
  99. void GUI_X_ExecIdle(void)
  100. {
  101.   vTaskDelay(30/portTICK_RATE_MS);
  102. }
  103. /*********************************************************************
  104. *
  105. * Multitasking:
  106. *
  107. * GUI_X_InitOS()
  108. * GUI_X_GetTaskId()
  109. * GUI_X_Lock()
  110. * GUI_X_Unlock()
  111. *
  112. * Note:
  113. * The following routines are required only if emWin is used in a
  114. * true multi task environment, which means you have more than one
  115. * thread using the emWin API.
  116. * In this case the
  117. * #define GUI_OS 1
  118. * needs to be in GUIConf.h
  119. */
  120. /* Init OS */
  121. void GUI_X_InitOS(void)
  122. {
  123.   /* Create Mutex lock */
  124.   xQueueMutex = xSemaphoreCreateMutex();
  125.   configASSERT (xQueueMutex != NULL);
  126.   
  127.   /* Queue Semaphore */
  128.   vSemaphoreCreateBinary( xSemaTxDone );
  129.   configASSERT ( xSemaTxDone != NULL );
  130. }
  131. void GUI_X_Unlock(void)
  132. {
  133.   xSemaphoreGive( xQueueMutex );
  134. }
  135. void GUI_X_Lock(void)
  136. {
  137.   if(xQueueMutex == NULL)
  138.   {
  139.     GUI_X_InitOS();
  140.   }
  141.   
  142.   xSemaphoreTake( xQueueMutex, portMAX_DELAY );
  143. }
  144. /* Get Task handle */
  145. U32 GUI_X_GetTaskId(void)
  146. {
  147.   return ((U32) xTaskGetCurrentTaskHandle());
  148. }
  149. void GUI_X_WaitEvent (void)
  150. {
  151.   while( xSemaphoreTake(xSemaTxDone, portMAX_DELAY ) != pdTRUE );
  152. }
  153. void GUI_X_SignalEvent (void)
  154. {
  155.   xSemaphoreGive( xSemaTxDone );
  156. }
  157. /*********************************************************************
  158. *
  159. * Logging: OS dependent
  160. Note:
  161. Logging is used in higher debug levels only. The typical target
  162. build does not use logging and does therefor not require any of
  163. the logging routines below. For a release build without logging
  164. the routines below may be eliminated to save some space.
  165. (If the linker is not function aware and eliminates unreferenced
  166. functions automatically)
  167. */
  168. void GUI_X_Log (const char *s) { }
  169. void GUI_X_Warn (const char *s) { }
  170. void GUI_X_ErrorOut(const char *s) { }
  171. /*************************** End of file ****************************/
复制代码
回复

使用道具 举报

10

主题

38

回帖

68

积分

初级会员

积分
68
 楼主| 发表于 2017-8-15 17:23:44 | 显示全部楼层
奇怪的是我换任务优先级就可以了,不知道是啥问题 ? 以前的任务优先级是 2,换成比 2 高的就正常了,这个是啥原因呢 ?
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107027
QQ
发表于 2017-8-16 01:59:45 | 显示全部楼层
下面这些代码,放到你的GUI任务里面试试,因为你的FreeRTOS还没有初始化,而emWin底层接口GUI_X_FreeROTS.c文件是要调用FreeRTOS的函数。

GUI_Init();
  GUI_SetBkColor(GUI_BLUE);
  GUI_SetColor(GUI_RED);
  GUI_Clear();
  GUI_SetFont(&GUI_Font8x18);
  GUI_DispString("test test test test");
回复

使用道具 举报

10

主题

38

回帖

68

积分

初级会员

积分
68
 楼主| 发表于 2017-8-16 22:37:50 | 显示全部楼层
发现调用这个函数会挂死
GUI_Delay(10);  
请问这个需要检查哪里呢 ?
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107027
QQ
发表于 2017-8-18 00:53:05 | 显示全部楼层

回 wendell.li 的帖子

wendell.li:发现调用这个函数会挂死
GUI_Delay(10);  
请问这个需要检查哪里呢 ? (2017-08-16 22:37) 
改成调用GUI_X_Delay还会死机不。
回复

使用道具 举报

10

主题

38

回帖

68

积分

初级会员

积分
68
 楼主| 发表于 2017-8-18 15:33:58 | 显示全部楼层

回 eric2013 的帖子

eric2013:改成调用GUI_X_Delay还会死机不。 (2017-08-18 00:53) 
会的。
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107027
QQ
发表于 2017-8-19 02:24:59 | 显示全部楼层

回 wendell.li 的帖子

wendell.li:会的。 (2017-08-18 15:33) 
帮不上了,[s:130]
从你当前的配置来看没有发现什么问题,我们这里的V4,V5和V6板子都有配置例子,对比下了:http://www.armbbs.cn/forum.php?mod=viewthread&tid=17658
回复

使用道具 举报

10

主题

38

回帖

68

积分

初级会员

积分
68
 楼主| 发表于 2017-8-19 14:45:20 | 显示全部楼层

回 eric2013 的帖子

eric2013:

帮不上了,[s:130]
从你当前的配置来看没有发现什么问题,我们这里的V4,V5和V6板子都有配置例子,对比下了:http://www.armbbs.cn/forum.php?mod=viewthread&tid=17658
会的。

HI  
    经过不断的排查,最终发现初始化的时候屏蔽掉串口的初始化部分的代码就正常了,如下是我串口的初始化的代码,没发现有什么异常呀,串口发送和接收都是正常的,请帮忙看看是否有地方会引起之前的问题,谢谢 , 还有事啥原因导致的呢 ?
   
  1. /*****************************************************************************
  2. *
  3. *    模块名称 : LED指示灯驱动模块
  4. *    文件名称 : bsp_uart.c
  5. *    版    本 : V1.0
  6. *    说    明 : 驱动串口
  7. *
  8. *    修改记录 :
  9. *        版本号  日期        作者     说明
  10. *        V1.0    2017-07-19 wendell  正式发布
  11. *
  12. *
  13. ******************************************************************************/
  14. #include "stm32f103_main.h"
  15. USART_TypeDef*  COM_USART[COMn] = {BSP_COM1, BSP_COM2};
  16. GPIO_TypeDef*   COM_TX_PORT[COMn] = {BSP_COM1_TX_GPIO_PORT, BSP_COM2_TX_GPIO_PORT};
  17. GPIO_TypeDef*   COM_RX_PORT[COMn] = {BSP_COM1_RX_GPIO_PORT, BSP_COM2_RX_GPIO_PORT};
  18. const uint32_t COM_USART_CLK[COMn] = {BSP_COM1_CLK, BSP_COM2_CLK};
  19. const uint32_t COM_TX_PORT_CLK[COMn] = {BSP_COM1_TX_GPIO_CLK, BSP_COM2_TX_GPIO_CLK};
  20. const uint32_t COM_RX_PORT_CLK[COMn] = {BSP_COM1_RX_GPIO_CLK, BSP_COM2_RX_GPIO_CLK};
  21. const uint16_t COM_TX_PIN[COMn] = {BSP_COM1_TX_PIN, BSP_COM2_TX_PIN};
  22. const uint16_t COM_RX_PIN[COMn] = {BSP_COM1_RX_PIN, BSP_COM2_RX_PIN};
  23. const uint16_t COM_IRQN[COMn] = {BSP_COM1_IRQn, BSP_COM2_IRQn};
  24. //外部变量
  25. //extern QueueHandle_t xQueue1;
  26. //extern SemaphoreHandle_t xSemaphore ;
  27. /*******************************************************************************
  28. *    函 数 名: Bsp_COMInit
  29. *    功能说明: 初始化一个 uart
  30. *    形    参:  COM : uart 号 com1 com2  baudrate :波特率
  31. *    返 回 值: 无
  32. *******************************************************************************/
  33. void Bsp_COMInit(COM_TypeDef COM, uint32_t baudrate)
  34. {
  35.   GPIO_InitTypeDef GPIO_InitStructure;
  36.   USART_InitTypeDef USART_InitStructure;
  37.   NVIC_InitTypeDef UARTNVIC_InitStructure;
  38.    
  39.   //使能 GPIO 时钟
  40.   RCC_APB2PeriphClockCmd(COM_TX_PORT_CLK[COM] | COM_RX_PORT_CLK[COM] | RCC_APB2Periph_AFIO, ENABLE);
  41.   //使能 UART 时钟
  42.   if (COM == COM1)
  43.   {
  44.     RCC_APB2PeriphClockCmd(COM_USART_CLK[COM], ENABLE);
  45.   }
  46.   else
  47.   {
  48.     RCC_APB1PeriphClockCmd(COM_USART_CLK[COM], ENABLE);
  49.   }
  50.   //配置 TX 推勉 输出
  51.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  52.   GPIO_InitStructure.GPIO_Pin = COM_TX_PIN[COM];
  53.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  54.   GPIO_Init(COM_TX_PORT[COM], &GPIO_InitStructure);
  55.   //配置 RX 浮空输入
  56.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  57.   GPIO_InitStructure.GPIO_Pin = COM_RX_PIN[COM];
  58.   GPIO_Init(COM_RX_PORT[COM], &GPIO_InitStructure);
  59.   
  60.   //中断配置
  61.   UARTNVIC_InitStructure.NVIC_IRQChannel = COM_IRQN[COM];
  62.   UARTNVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0 ;
  63.   UARTNVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  64.   UARTNVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  65.   NVIC_Init(&UARTNVIC_InitStructure);
  66.   
  67.   USART_InitStructure.USART_BaudRate = baudrate;
  68.   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  69.   USART_InitStructure.USART_StopBits = USART_StopBits_1;
  70.   USART_InitStructure.USART_Parity = USART_Parity_No;
  71.   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  72.   USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
  73.   // 串口特性设置
  74.   USART_Init(COM_USART[COM], &USART_InitStructure);
  75.   //开启串口接受中断
  76.   USART_ITConfig(COM_USART[COM], USART_IT_RXNE, ENABLE);
  77.   //使能设置
  78.   USART_Cmd(COM_USART[COM], ENABLE);
  79.   //避免第一个字节发布出去
  80.   USART_ClearFlag(COM_USART[COM], USART_FLAG_TC);
  81. }
  82. /*******************************************************************************
  83. *    函 数 名: Bsp_SendDate
  84. *    功能说明: 初始化一个 uart
  85. *    形    参:  COM : COMx 号 com1 com2  Data :数据
  86. *    返 回 值: 无
  87. *******************************************************************************/
  88. void Bsp_SendDate(COM_TypeDef COMx, uint8_t Data )
  89. {
  90.   USART_SendData(COM_USART[COMx], (uint8_t) Data);
  91.   while (USART_GetFlagStatus(COM_USART[COMx], USART_FLAG_TC) == RESET);
  92. }
  93. /*
  94. *********************************************************************************************************
  95. *    函 数 名: fputc
  96. *    功能说明: 重定义putc函数,这样可以使用printf函数从串口1打印输出
  97. *    形    参: 无
  98. *    返 回 值: 无
  99. *********************************************************************************************************
  100. */
  101. int fputc(int ch, FILE *f)
  102. {
  103.     Bsp_SendDate(COM2,ch);
  104.     return ch;
  105. }
  106. /*
  107. *********************************************************************************************************
  108. *    函 数 名: USART2_IRQHandler
  109. *    功能说明: 重定义putc函数,这样可以使用printf函数从串口1打印输出
  110. *    形    参: 无
  111. *    返 回 值: 无
  112. *********************************************************************************************************
  113. */
  114. void USART2_IRQHandler(void)
  115. {
  116.   uint8_t ch;
  117.   UBaseType_t uxSavedInterruptStatus;
  118.   uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); /* 进入临界区 */
  119.   //BaseType_t xHigherPriorityTaskWoken = pdFALSE;
  120.   if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET)
  121.   {
  122.     ch = USART_ReceiveData(USART2);
  123.     if (ch == 0xa5)
  124.     {
  125.     }
  126.     if(USART_GetITStatus(USART2, USART_IT_TXE) != RESET)                  
  127.     {
  128.       USART_ITConfig(USART2, USART_IT_TXE, DISABLE);               
  129.     }
  130.   }
  131.   //退出临界区
  132.   portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
  133. }
复制代码
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107027
QQ
发表于 2017-8-21 01:17:42 | 显示全部楼层
中断优先级配置有问题,详细看下我们FreeRTOS教程的第12章节,专门讲解了这个问题。
http://www.armbbs.cn/forum.php?mod=viewthread&tid=17658
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-14 13:34 , Processed in 0.230915 second(s), 28 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表