[电机控制专用MCU] 【APM32M3514电机通用评估板测评】开箱+闪灯

[复制链接]
 楼主| hayden0 发表于 2025-3-4 22:01 | 显示全部楼层 |阅读模式
本帖最后由 hayden0 于 2025-3-4 22:09 编辑

首先感谢21IC和极海给予的这次测试机会,开发板早就到了,本来第一个帖子想先发启动电机,但我的时候发现高压电机参数不好调,转动会振荡,不能使用FOC例程流畅驱动,又换了航模无刷电机也是不行,应该是参数没调整正确,我又是刚接触FOC,所以准备官网其他大佬的测评帖,等了一段时间,发现不少其他玩家也遇到了我同样的问题,希望官方能指导一下,解决大家问题。在此之前就先发一个开箱点灯帖吧,不然测评过期了还没发帖,管理在催了

571167c70868ed85a.jpg 3851267c7087defd09.png 8352167c70898afda0.jpg

开箱:没想到居然还有包装盒和说明书,太正规了
对于arm cortex-m0+内核来说,开发步骤大同小异,在keil mdk中安装极海支持包pack就行了。
由SOC资料珠海极海半导体有限公司 | APM32电机控制专用SoC可知APM32M3514是基于APM32M035单片机为核心的。
片上资源丰富



1、开发环境搭建
keil mdk是最完善常用的开发环境了,安装支持包Geehy.APM32M35XX_DFP.1.0.0.pack
3795767c6d6e96eb8c.png
2、下载SDK,打开官方例程,感觉原理图修改程序
APM32M35xx_SDK_V1.0.0.zip
这是官方闪灯程序,我连接了DAPlink下载器,使用的SWD接口。
426967c7001abeda9.png

由板子原理图可知默认LED灯接到了PA12脚
4793267c703ab74c22.png 9841467c703ca523d6.png
而GPIO_Toggle例程是用的PC0 PC1
9210867c70468d9f43.png 6488867c70481a7c42.png
所以需要更改程序,重新定义LED的GPIO

  1. #define LED2_PIN                         GPIO_PIN_12
  2. #define LED2_GPIO_PORT                   GPIOA
  3. #define LED2_GPIO_CLK                    RCM_AHB_PERIPH_GPIOA
3、编译程序,然后下载

2590567c705ec79bbe.png
主程序代码:
  1. /*!
  2. * [url=home.php?mod=space&uid=288409]@file[/url]        main.c
  3. *
  4. * [url=home.php?mod=space&uid=247401]@brief[/url]       Main program body
  5. *
  6. * [url=home.php?mod=space&uid=895143]@version[/url]     V1.0.0
  7. *
  8. * [url=home.php?mod=space&uid=212281]@date[/url]        2024-05-30
  9. *
  10. * @attention
  11. *
  12. *  Copyright (C) 2024 Geehy Semiconductor
  13. *
  14. *  You may not use this file except in compliance with the
  15. *  GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
  16. *
  17. *  The program is only for reference, which is distributed in the hope
  18. *  that it will be useful and instructional for customers to develop
  19. *  their software. Unless required by applicable law or agreed to in
  20. *  writing, the program is distributed on an "AS IS" BASIS, WITHOUT
  21. *  ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
  22. *  See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
  23. *  and limitations under the License.
  24. */

  25. /* Includes */
  26. #include "main.h"
  27. #include "bsp_delay.h"
  28. #include "apm32m35xx_rcm.h"
  29. #include "apm32m35xx_gpio.h"
  30. #include "apm32m35xx_misc.h"
  31. #include <stdio.h>
  32. #include <string.h>


  33. /** @addtogroup Examples
  34.   * [url=home.php?mod=space&uid=247401]@brief[/url] GPIO toggle examples
  35.   @{
  36.   */

  37. /** @addtogroup GPIO_Toggle
  38.   @{
  39.   */

  40. /** @defgroup GPIO_Toggle_Macros Macros
  41.   @{
  42. */

  43. /* printf using USART1  */
  44. #define DEBUG_USART             USART1

  45. /**@} end of group GPIO_Toggle_Macros*/

  46. /** @defgroup GPIO_Toggle_Functions Functions
  47.   @{
  48.   */

  49. void APM_MINI_Init(void);
  50. void GPIO_Init(void);

  51. /*!
  52. * [url=home.php?mod=space&uid=247401]@brief[/url]       Main program
  53. *
  54. * @param       None
  55. *
  56. * @retval      None
  57. *
  58. */
  59. int main(void)
  60. {
  61.     APM_MINI_Init();

  62.     GPIO_Init();

  63.     printf("This is an example of GPIO toggle \r\n");

  64.     while (1)
  65.     {
  66.         /* Turn LED2 on */
  67.         GPIO_ClearBit(LED2_GPIO_PORT, LED2_PIN);
  68.         /* Turn LED3 off */
  69.         GPIO_SetBit(LED3_GPIO_PORT, LED3_PIN);
  70.         APM_DelayMs(200);

  71.         /* Turn LED2 off */
  72.         GPIO_SetBit(LED2_GPIO_PORT, LED2_PIN);
  73.         /* Turn LED3 on */
  74.         GPIO_ClearBit(LED3_GPIO_PORT, LED3_PIN);
  75.         APM_DelayMs(200);
  76.     }
  77. }

  78. /*!
  79. * @brief       Init MINI board
  80. *
  81. * @param       None
  82. *
  83. * @retval      None
  84. *
  85. * @note
  86. */
  87. void APM_MINI_Init(void)
  88. {
  89.     /* Init delay function */
  90.     APM_DelayInit();

  91.     APM_MINI_PBInit(BUTTON_KEY1, BUTTON_MODE_GPIO);
  92.     APM_MINI_COMInit(COM1);
  93. }

  94. /*!
  95. * @brief       GPIO initialization
  96. *
  97. * @param       None
  98. *
  99. * @retval      None
  100. *
  101. */
  102. void GPIO_Init(void)
  103. {
  104.     GPIO_Config_T gpioConfig;

  105.     RCM_EnableAHBPeriphClock(LED2_GPIO_CLK | LED3_GPIO_CLK);
  106.     /* LED2 GPIO configuration */
  107.     gpioConfig.pin = LED2_PIN;
  108.     gpioConfig.mode = GPIO_MODE_OUT;
  109.     gpioConfig.outtype = GPIO_OUT_TYPE_PP;
  110.     gpioConfig.speed = GPIO_SPEED_50MHz;
  111.     gpioConfig.pupd = GPIO_PUPD_NO;
  112.     GPIO_Config(LED2_GPIO_PORT, &gpioConfig);

  113.     /* LED3 GPIO configuration */
  114.     gpioConfig.pin = LED3_PIN;
  115.     GPIO_Config(LED3_GPIO_PORT, &gpioConfig);
  116. }

  117. #if defined (__CC_ARM) || defined (__ICCARM__) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))

  118. /*!
  119. * @brief       Redirect C Library function printf to serial port.
  120. *              After Redirection, you can use printf function.
  121. *
  122. * @param       ch:  The characters that need to be send.
  123. *
  124. * @param       *f:  pointer to a FILE that can recording all information
  125. *              needed to control a stream
  126. *
  127. * @retval      The characters that need to be send.
  128. *
  129. * @note
  130. */
  131. int fputc(int ch, FILE* f)
  132. {
  133.     /* send a byte of data to the serial port */
  134.     USART_TxData(DEBUG_USART, (uint8_t)ch);

  135.     /* wait for the data to be send  */
  136.     while (USART_ReadStatusFlag(DEBUG_USART, USART_FLAG_TXBE) == RESET);

  137.     return (ch);
  138. }

  139. #elif defined (__GNUC__)

  140. /*!
  141. * @brief       Redirect C Library function printf to serial port.
  142. *              After Redirection, you can use printf function.
  143. *
  144. * @param       ch:  The characters that need to be send.
  145. *
  146. * @retval      The characters that need to be send.
  147. *
  148. * @note
  149. */
  150. int __io_putchar(int ch)
  151. {
  152.     /* send a byte of data to the serial port */
  153.     USART_TxData(DEBUG_USART, ch);

  154.     /* wait for the data to be send  */
  155.     while (USART_ReadStatusFlag(DEBUG_USART, USART_FLAG_TXBE) == RESET);

  156.     return ch;
  157. }

  158. /*!
  159. * @brief       Redirect C Library function printf to serial port.
  160. *              After Redirection, you can use printf function.
  161. *
  162. * @param       file:  Meaningless in this function.
  163. *
  164. * @param       *ptr:  Buffer pointer for data to be sent.
  165. *
  166. * @param       len:  Length of data to be sent.
  167. *
  168. * @retval      The characters that need to be send.
  169. *
  170. * @note
  171. */
  172. int _write(int file, char* ptr, int len)
  173. {
  174.     int i;
  175.     for (i = 0; i < len; i++)
  176.     {
  177.         __io_putchar(*ptr++);
  178.     }

  179.     return len;
  180. }

  181. #else
  182. #warning Not supported compiler type
  183. #endif

  184. /**@} end of group GPIO_Toggle_Functions */
  185. /**@} end of group GPIO_Toggle */
  186. /**@} end of group Examples */
4、下载后复位,程序开始运行,如果勾选自动复位,程序就不用手动复位了。

4318767c7065c0fa64.png

运行结果:
2607467c706fe9568d.gif

工程源码: GPIO_Toggle.zip (826.67 KB, 下载次数: 1)

  
jobszheng 发表于 2025-3-30 18:09 | 显示全部楼层
羡慕一下,当时我也申请了。
看着楼主玩了!话说,电机也是极海赠送的吗?
 楼主| hayden0 发表于 2025-4-5 21:36 | 显示全部楼层
jobszheng 发表于 2025-3-30 18:09
羡慕一下,当时我也申请了。
看着楼主玩了!话说,电机也是极海赠送的吗? ...

只有开发板,电机不是送的
chenjun89 发表于 2025-4-5 21:51 来自手机 | 显示全部楼层
我也以为电机是送的,如果是这样那真的太贴心了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

62

主题

295

帖子

3

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

62

主题

295

帖子

3

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