[开发工具] 新定义MCU开发板测评 +定时器0LED点灯

[复制链接]
 楼主| 比神乐 发表于 2022-11-21 07:05 | 显示全部楼层 |阅读模式
本帖最后由 比神乐 于 2022-11-21 07:07 编辑

用易码魔盒生成了一个模板,用定时器0中断定时使LED灯闪烁。
代码:
  1. //************************************************************
  2. //  Copyright (c)  
  3. //        FileName         : main.c
  4. //        Module Function        :
  5. //  Instructions : Contains the MCU initialization function and its H file
  6. //************************************************************
  7. /********************Includes************************************************************************/
  8. #include "SC_Init.h"        //MCU Init header,Include all IC resource headers
  9. #include "SC_it.h"
  10. #include "..\Drivers\SCDriver_list.h"
  11. #include "HeadFiles\SysFunVarDefine.h"
  12. /**************************************Generated by EasyCodeCube*************************************/

  13. /*************************************.Generated by EasyCodeCube.************************************/
  14. /*****************************************************************************************************
  15. * Function Name: main
  16. * Description  : This function implements main function.
  17. * Arguments    : None
  18. * Return Value : None
  19. ******************************************************************************************************/
  20. void main(void)
  21. {        
  22.     /*<Generated by EasyCodeCube begin>*/
  23.     /*<UserCodeStart>*//*<SinOne-Tag><3>*/
  24.     SC_Init(); /*** MCU init***/
  25.     /*<UserCodeEnd>*//*<SinOne-Tag><3>*/
  26.     /*<UserCodeStart>*//*<SinOne-Tag><4>*/
  27.     /*****MainLoop*****/
  28.     while(1)
  29.     {
  30.         /*<UserCodeStart>*//*<SinOne-Tag><5>*/
  31.         /*****User program*****/
  32.         /*<UserCodeEnd>*//*<SinOne-Tag><5>*/
  33.         /*<Begin-Inserted by EasyCodeCube for Condition>*/
  34.     }
  35.     /*<UserCodeEnd>*//*<SinOne-Tag><4>*/
  36.     /*<Generated by EasyCodeCube end>*/
  37. }

  38. /*****************************************************
  39. *函数名称: SC_Init
  40. *函数功能: MCU初始化函数
  41. *入口参数:void
  42. *出口参数:void
  43. *****************************************************/
  44. void SC_Init(void)
  45. {
  46.         SC_GPIO_Init();
  47.         SC_OPTION_Init();
  48.         SC_TIM0_Init();
  49.         /*write initial function here*/        
  50.         EA = 1;        
  51. }

  52. void Timer0Interrupt()                interrupt 1                           
  53. {
  54.     /*TIM0_it write here begin*/
  55.     TIM0_Mode1SetReloadCounter(1000);
  56.         
  57.                 if(cnt>=1000)
  58.                 {
  59.                         cnt=0;
  60.                         GPIO_TogglePin(GPIO0,GPIO_PIN_1);
  61.                 }
  62.                 cnt++;
  63.     /*TIM0_it write here*/
  64.     /*<Generated by EasyCodeCube begin>*/
  65.     /*<UserCodeStart>*//*<SinOne-Tag><6>*/
  66.     //Timer0Interrupt
  67.     {
  68.         /*<UserCodeStart>*//*<SinOne-Tag><7>*/
  69.         /*****User program*****/
  70.         /*<UserCodeEnd>*//*<SinOne-Tag><7>*/
  71.         /*<Begin-Inserted by EasyCodeCube for Condition>*/
  72.     }
  73.     /*<UserCodeEnd>*//*<SinOne-Tag><6>*/
  74.     /*<Generated by EasyCodeCube end>*/
  75.     /*Timer0Interrupt Flag Clear begin*/
  76.     /*Timer0Interrupt Flag Clear end*/               
  77. }
效果图
0.jpg 1.jpg
您需要登录后才可以回帖 登录 | 注册

本版积分规则

470

主题

3535

帖子

7

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

470

主题

3535

帖子

7

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