标题: HC32F460开发板的程序下载及LED控制 [打印本页]

作者: jinglixixi    时间: 2020-11-5 00:32
标题: HC32F460开发板的程序下载及LED控制
我使用的HC32F460开发板是基于HC32F460JETA,共有48个引脚。所使用的开发工具,则是第三方的雅特力调试下载器AT_LINK
该开发板有别于原厂的HC32F460开发板,其LED灯的原理图见图1所示。

1  LED灯原理图
为此,为了控制LED灯所做得定义如下:
/* LED2 Port/Pin definition */
#define LED2_PORT       (PortB)
#define LED2_PIN        (Pin15)
/* LED3 Port/Pin definition */
#define LED3_PORT       (PortB)
#define LED3_PIN        (Pin14)
/* LED0~3 toggle definition */
#define LED2_TOGGLE()   (PORT_Toggle(LED2_PORT,LED2_PIN))
#define LED3_TOGGLE()   (PORT_Toggle(LED3_PORT,LED3_PIN))
#define DLY_MS          (100ul)
控制LED灯的主程序为:
  1. int32_t main(void)
  2. {
  3. stc_port_init_t stcPortInit;
  4. /* configuration structure initialization */
  5. MEM_ZERO_STRUCT(stcPortInit);
  6. stcPortInit.enPinMode = Pin_Mode_Out;
  7. stcPortInit.enExInt = Enable;
  8. stcPortInit.enPullUp = Enable;
  9. /* LED2 Port/Pin initialization */
  10. PORT_Init(LED2_PORT, LED2_PIN, &stcPortInit);
  11. /* LED3 Port/Pin initialization */
  12. PORT_Init(LED3_PORT, LED3_PIN, &stcPortInit);
  13. while(1)
  14. {
  15. LED2_TOGGLE();
  16. Ddl_Delay1ms(DLY_MS);
  17. LED3_TOGGLE();
  18. Ddl_Delay1ms(DLY_MS);
  19. };
  20. }
复制代码

有了程序,后面要解决的问题就是程序编译和下载了。
KEIL的开发环境下,需按图2~4来进行设置。

2 选取芯片类型

3 激活调试工具

4 选择烧录算法
程序编译下载后,其效果如图5所示。

5点亮单灯







欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1