[开发板与模块] 【ESK32-30519 + ESK32-21001测评】+浅用Freertos

[复制链接]
 楼主| 夜声 发表于 2022-9-10 21:42 | 显示全部楼层 |阅读模式
<
本帖最后由 夜声 于 2022-9-13 17:54 编辑

#申请原创#[url=home.php?mod=space&uid=760190]@21小跑堂 [/url] 如我所愿,在中秋节前这块板子到了我的手上,板子非常大一个,刚拿到也有点意外,在这里也感谢21ic和合泰能给我这次测评的机会。外观如下图所示: 板子外观.jpg
板子很大,看起来也很大气,不过这个SDcard好大一个,应该很少能用上吧。接下来就是了解这个芯片的资料,直接上懒人包https://mcu.holtek.com.cn/ht32/resource/,将M0的全部下载下来。
懒人包.jpg
在HT32M0\HT32_M0p_V20220611\Firmware_Library\project_template\IP\Example\MDK_ARMv5这个路径下找到工程文件夹,全部都是放在这里的,刚开始用还有点不习惯,第一次遇到将所有的工程文件放在一起的。找到HT3254253这个工程文件,后面就以这个文件进行开发,不用花其他时间去整理,新建也比较麻烦。
工程文件.jpg
接下来下载Freertos源码,将源码复制到工程里面来
源码.jpg
删除掉不使用的一些文件夹,留下RVDS以及MEM管理算法这两个文件夹即可
删除一部分.jpg
接下来在工程添加Freertos的源码,添加源码
.c文件.jpg
添加头文件路径
头文件路径.jpg
接下来屏蔽掉it.c中的三个文件夹。
屏蔽三个文件.jpg
自己弄一个FreeRTOSConfig.h进行裁剪
配置文件.jpg
接下来在主函数中创建三个线程,一个线程为启动线程,一个为LED1,还有一个为LED2,如下所示。
  1. /*********************************************************************************************************//**
  2. * [url=home.php?mod=space&uid=288409]@file[/url]    IP/Example/main.c
  3. * [url=home.php?mod=space&uid=895143]@version[/url] $Rev:: 4869         $
  4. * [url=home.php?mod=space&uid=212281]@date[/url]    $Date:: 2020-08-05 #$
  5. * [url=home.php?mod=space&uid=247401]@brief[/url]   Main program.
  6. *************************************************************************************************************
  7. * @attention
  8. *
  9. * Firmware Disclaimer Information
  10. *
  11. * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the
  12. *    code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the
  13. *    proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and
  14. *    other intellectual property laws.
  15. *
  16. * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the
  17. *    code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties
  18. *    other than HOLTEK and the customer.
  19. *
  20. * 3. The program technical documentation, including the code, is provided "as is" and for customer reference
  21. *    only. After delivery by HOLTEK, the customer shall use the program technical documentation, including
  22. *    the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including
  23. *    the warranties of merchantability, satisfactory quality and fitness for a particular purpose.
  24. *
  25. * <h2><center>Copyright (C) Holtek Semiconductor Inc. All rights reserved</center></h2>
  26. ************************************************************************************************************/
  27. // <<< Use Configuration Wizard in Context Menu >>>

  28. /* Includes ------------------------------------------------------------------------------------------------*/
  29. #include "ht32.h"
  30. #include "ht32_board.h"
  31. #include "FreeRTOS.h"
  32. #include "task.h"
  33. #include "ht32f5xxxx_gpio.h"

  34. /* Settings ------------------------------------------------------------------------------------------------*/
  35. /* Private types -------------------------------------------------------------------------------------------*/
  36. /* Private constants ---------------------------------------------------------------------------------------*/
  37. /* Private function prototypes -----------------------------------------------------------------------------*/
  38. void NVIC_Configuration(void);
  39. void CKCU_Configuration(void);
  40. void GPIO_Configuration(void);
  41. #if (ENABLE_CKOUT == 1)
  42. void CKOUTConfig(void);
  43. #endif



  44. //任务堆栈大小
  45. #define LED1_TASK_STACK              256
  46. #define LED2_TASK_STACK             256

  47. //任务优先级
  48. #define LED1_TASK_PRIORITY            5
  49. #define LED2_TASK_PRIORITY           3




  50. xTaskHandle startTask;
  51. xTaskHandle LED1Task;
  52. xTaskHandle LED2Task;


  53. portTASK_FUNCTION(vLED1Task, pvParameters)
  54. {
  55.         while(1)
  56.         {
  57.      HT32F_DVB_LEDOn(HT_LED1);
  58.      vTaskDelay(200);
  59.          HT32F_DVB_LEDOff(HT_LED1);
  60.          vTaskDelay(200);
  61.         }
  62. }

  63. portTASK_FUNCTION(vLED2Task, pvParameters)
  64. {        
  65.         while(1)
  66.         {
  67.      HT32F_DVB_LEDOn(HT_LED2);
  68.      vTaskDelay(500);
  69.          HT32F_DVB_LEDOff(HT_LED2);
  70.          vTaskDelay(500);
  71.         }
  72. }


  73. /**********************************************************************************************************
  74. *函 数 名: vStartTask
  75. *功能说明: 系统启动任务,调用各类初始化函数,并创建消息队列和要运行的用户任务
  76. *形    参: 无
  77. *返 回 值: 无
  78. **********************************************************************************************************/
  79. portTASK_FUNCTION(vStartTask, pvParameters)
  80. {
  81.         xTaskCreate(vLED1Task, (char const*)"SensorReadTask",LED1_TASK_STACK, NULL, LED1_TASK_PRIORITY, &LED1Task);
  82.         xTaskCreate(vLED2Task, (char const*)"SensorUpdateTask",LED2_TASK_STACK, NULL,LED2_TASK_PRIORITY, &LED2Task);
  83.         
  84.         //删除本任务
  85.   vTaskDelete(NULL);
  86. }

  87.         

  88. /* Private macro -------------------------------------------------------------------------------------------*/
  89. /* Global variables ----------------------------------------------------------------------------------------*/
  90. /* Private variables ---------------------------------------------------------------------------------------*/
  91. /* Global functions ----------------------------------------------------------------------------------------*/
  92. /*********************************************************************************************************//**
  93.   * [url=home.php?mod=space&uid=247401]@brief[/url]  Main program.
  94.   * @retval None
  95.   ***********************************************************************************************************/
  96. int main(void)
  97. {
  98.         
  99.   NVIC_Configuration();               /* NVIC configuration                                                 */
  100.   CKCU_Configuration();               /* System Related configuration                                       */
  101.   GPIO_Configuration();               /* GPIO Related configuration                                         */
  102.   RETARGET_Configuration();           /* Retarget Related configuration                                     */

  103.   HT32F_DVB_LEDInit(HT_LED1);
  104.   HT32F_DVB_LEDInit(HT_LED2);
  105.   HT32F_DVB_LEDInit(HT_LED3);
  106.   HT32F_DVB_LEDOn(HT_LED1);
  107.   HT32F_DVB_LEDOff(HT_LED2);
  108.   HT32F_DVB_LEDOn(HT_LED3);

  109.             //创建启动任务
  110.     xTaskCreate(vStartTask, "startTask", 128, NULL, 0, &startTask);
  111.     //OS调度器启动
  112.     vTaskStartScheduler();

  113. //  while (1)                           /* Infinite loop                                                      */
  114. //  {
  115. //   
  116. //     HT32F_DVB_LEDOn(HT_LED1);
  117. //     vTaskDelay(500);
  118. //         HT32F_DVB_LEDOff(HT_LED1);
  119. //         vTaskDelay(500);
  120. //  }
  121. }

  122. /*********************************************************************************************************//**
  123.   * @brief  Configure the NVIC vector table.
  124.   * @retval None
  125.   ***********************************************************************************************************/
  126. void NVIC_Configuration(void)
  127. {
  128.   NVIC_SetVectorTable(NVIC_VECTTABLE_FLASH, 0x0);     /* Set the Vector Table base location at 0x00000000   */
  129. }

  130. /*********************************************************************************************************//**
  131.   * @brief  Configure the system clocks.
  132.   * @retval None
  133.   ***********************************************************************************************************/
  134. void CKCU_Configuration(void)
  135. {
  136. /*
  137. //<e0> Enable Peripheral Clock
  138. //  <h> Communication
  139. //    <q5> EBI
  140. //    <q11> I2C0   <q12> I2C1
  141. //    <q23> I2S
  142. //    <q21> SCI0 <q22> SCI1
  143. //    <q13> SPI0   <q14> SPI1
  144. //    <q17> UART0  <q18> UART1
  145. //    <q15> USART0 <q16> USART1
  146. //    <q3>  USB
  147. //  </h>
  148. //  <h> IO
  149. //    <q7> GPIO Port A <q8>  GPIO Port B <q9>  GPIO Port C <q10>  GPIO Port D
  150. //    <q19> AFIO
  151. //    <q20> EXTI
  152. //  </h>
  153. //  <h> System
  154. //    <q32> ADC
  155. //    <q4>  CKREF
  156. //    <q6>  CRC
  157. //    <q31> CMP
  158. //    <q2>  PDMA
  159. //    <q26> PWRCU
  160. //  </h>
  161. //  <h> Timer
  162. //    <q29> BFTM0 <q30> BFTM1
  163. //    <q33> SCTM0 <q34> SCTM1 <q35> SCTM2 <q36> SCTM3
  164. //    <q27> GPTM0 <q28> GPTM1
  165. //    <q24> MCTM0
  166. //    <q26> RTC   <q25> WDT
  167. //  </h>
  168. //</e>
  169. */
  170. #if 1
  171.   CKCU_PeripClockConfig_TypeDef CKCUClock = {{ 0 }};
  172.   CKCUClock.Bit.PDMA       = 0;
  173.   CKCUClock.Bit.USBD       = 0;
  174.   CKCUClock.Bit.CKREF      = 0;
  175.   CKCUClock.Bit.EBI        = 0;
  176.   CKCUClock.Bit.CRC        = 0;
  177.   CKCUClock.Bit.PA         = 0;
  178.   CKCUClock.Bit.PB         = 0;
  179.   CKCUClock.Bit.PC         = 0;
  180.   CKCUClock.Bit.PD         = 0;
  181.   CKCUClock.Bit.I2C0       = 0;
  182.   CKCUClock.Bit.I2C1       = 0;
  183.   CKCUClock.Bit.SPI0       = 0;
  184.   CKCUClock.Bit.SPI1       = 0;
  185.   CKCUClock.Bit.USART0     = 1;
  186.   CKCUClock.Bit.USART1     = 1;
  187.   CKCUClock.Bit.UART0      = 1;
  188.   CKCUClock.Bit.UART1      = 1;
  189.   CKCUClock.Bit.AFIO       = 1;
  190.   CKCUClock.Bit.EXTI       = 0;
  191.   CKCUClock.Bit.SCI0       = 0;
  192.   CKCUClock.Bit.SCI1       = 0;
  193.   CKCUClock.Bit.I2S        = 0;
  194.   CKCUClock.Bit.MCTM0      = 0;
  195.   CKCUClock.Bit.WDT        = 0;
  196.   CKCUClock.Bit.BKP        = 0;
  197.   CKCUClock.Bit.GPTM0      = 0;
  198.   CKCUClock.Bit.GPTM1      = 0;
  199.   CKCUClock.Bit.BFTM0      = 0;
  200.   CKCUClock.Bit.BFTM1      = 0;
  201.   CKCUClock.Bit.CMP        = 0;
  202.   CKCUClock.Bit.ADC        = 0;
  203.   CKCUClock.Bit.SCTM0      = 0;
  204.   CKCUClock.Bit.SCTM1      = 0;
  205.   CKCUClock.Bit.SCTM2      = 0;
  206.   CKCUClock.Bit.SCTM3      = 0;
  207.   CKCU_PeripClockConfig(CKCUClock, ENABLE);
  208. #endif

  209. #if (ENABLE_CKOUT == 1)
  210.   CKOUTConfig();
  211. #endif
  212. }

  213. #if (ENABLE_CKOUT == 1)
  214. /*********************************************************************************************************//**
  215.   * @brief  Configure the debug output clock.
  216.   * @retval None
  217.   ***********************************************************************************************************/
  218. void CKOUTConfig(void)
  219. {
  220.   { /* Enable peripheral clock                                                                              */
  221.     CKCU_PeripClockConfig_TypeDef CKCUClock = {{ 0 }};
  222.     CKCUClock.Bit.AFIO = 1;
  223.     CKCU_PeripClockConfig(CKCUClock, ENABLE);
  224.   }

  225.   AFIO_GPxConfig(GPIO_PA, AFIO_PIN_9, AFIO_MODE_15);

  226.   { /* Configure CKOUT                                                                                      */
  227.     CKCU_CKOUTInitTypeDef CKOUTInit;
  228.     CKOUTInit.CKOUTSRC = CKCU_CKOUTSRC_HCLK_DIV16;
  229.     CKCU_CKOUTConfig(&CKOUTInit);
  230.   }
  231. }
  232. #endif

  233. /*********************************************************************************************************//**
  234.   * @brief  Configure the GPIO ports.
  235.   * @retval None
  236.   ***********************************************************************************************************/
  237. void GPIO_Configuration(void)
  238. {
  239.   /* !!! NOTICE !!!
  240.      Shall be modified according to the part number.
  241.   */
  242. #if (RETARGET_PORT == RETARGET_USART0)
  243.   //AFIO_GPxConfig(GPIO_PA, AFIO_PIN_2 | AFIO_PIN_3, AFIO_FUN_USART_UART);
  244. #endif

  245. #if (RETARGET_PORT == RETARGET_USART1)
  246.   //AFIO_GPxConfig(GPIO_PA, AFIO_PIN_4 | AFIO_PIN_5, AFIO_FUN_USART_UART);
  247. #endif

  248. #if (RETARGET_PORT == RETARGET_UART0)
  249.   //AFIO_GPxConfig(GPIO_PC, AFIO_PIN_4 | AFIO_PIN_5, AFIO_FUN_USART_UART);
  250. #endif

  251. #if (RETARGET_PORT == RETARGET_UART1)
  252.   //AFIO_GPxConfig(GPIO_PC, AFIO_PIN_1 | AFIO_PIN_3, AFIO_FUN_USART_UART);
  253. #endif
  254. }

  255. #if (HT32_LIB_DEBUG == 1)
  256. /*********************************************************************************************************//**
  257.   * @brief  Report both the error name of the source file and the source line number.
  258.   * @param  filename: pointer to the source file name.
  259.   * @param  uline: error line source number.
  260.   * @retval None
  261.   ***********************************************************************************************************/
  262. void assert_error(u8* filename, u32 uline)
  263. {
  264.   /*
  265.      This function is called by IP library that the invalid parameters has been passed to the library API.
  266.      Debug message can be added here.
  267.      Example: printf("Parameter Error: file %s on line %d\r\n", filename, uline);
  268.   */

  269.   while (1)
  270.   {
  271.   }
  272. }
  273. #endif

实现结果,可以发现LED2闪得比较快,200ms,LED相对比较慢,500ms。
tutieshi_640x288_3s.gif

weifeng90 发表于 2022-9-10 22:52 来自手机 | 显示全部楼层
这套开发板两个板子?

评论

有个扩展板  发表于 2022-9-11 08:45
海滨消消 发表于 2022-9-13 15:15 来自手机 | 显示全部楼层
这开发板真的够大的
海滨消消 发表于 2022-9-13 15:16 来自手机 | 显示全部楼层
很少看到这么大的开发板
Stahan 发表于 2022-9-13 21:17 | 显示全部楼层
这开发板真大
bestwell 发表于 2022-10-9 21:37 | 显示全部楼层
freertos要学多长时间        
macpherson 发表于 2022-10-9 21:46 | 显示全部楼层
freertos任务切换需要多少个时钟周期
nomomy 发表于 2022-10-9 22:11 | 显示全部楼层
FreeRTOS和UCOSIII哪个更适合     
232321122 发表于 2022-10-9 22:43 | 显示全部楼层
freertos时实系统的栈最大是多少
isseed 发表于 2022-10-10 17:38 | 显示全部楼层
freertos占用多少ram           
isseed 发表于 2022-10-10 20:07 | 显示全部楼层
在学习freertos之前,应学习哪些东西
gygp 发表于 2023-1-5 12:20 | 显示全部楼层
这个非常详细的Freertos移植教程。
ccook11 发表于 2023-1-5 18:23 | 显示全部楼层
可配置转换片轮的时间吗?              
chenjun89 发表于 2023-1-5 23:20 来自手机 | 显示全部楼层
嗯,这个开发板够良心啊,外部资源配置还多。
robertesth 发表于 2023-1-6 17:06 | 显示全部楼层
Freertos怎么调用定时器?
elsaflower 发表于 2023-1-6 17:56 | 显示全部楼层
板子非常棒,期待楼主更多的分享。
loutin 发表于 2023-1-6 18:55 | 显示全部楼层
请问,不同任务之间是如何通信的?
febgxu 发表于 2023-1-6 19:46 | 显示全部楼层
最多建立几个任务?              
yorkbarney 发表于 2023-1-6 20:17 | 显示全部楼层
Freertos内可以使用外部中断的吗?
zerorobert 发表于 2023-1-6 20:47 | 显示全部楼层
Freertos应用的真是多。              
您需要登录后才可以回帖 登录 | 注册

本版积分规则

27

主题

89

帖子

2

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