main.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. @copyright None
  3. @file main.c
  4. @author Comment Vivre
  5. @date 2025-10-31
  6. @brief 主函数 主循环
  7. */
  8. #include <Myproject.h>
  9. /**
  10. @function main
  11. @brief 主函数 电机驱动主循环 任务循环
  12. @date 2025-10-31
  13. */
  14. void main(void)
  15. {
  16. HardwareInit();
  17. SoftwareInit();
  18. EA = 1;
  19. _nop_(); _nop_(); _nop_();
  20. WatchDogConfig(600, Enable);
  21. while (1)
  22. {
  23. if (flag_1ms_main == 1)
  24. {
  25. main_ms();
  26. flag_1ms_main = 0;
  27. }
  28. GetCurrentOffset();
  29. MC_Control(); // 压机主控函数,状态扫描 2.6k
  30. User_Dri_main(); //用户使用主函数
  31. //ptc母线继电器1s后动作
  32. if (Time.PowerOnCnt >= 5000)
  33. {
  34. PTC_RELAY = 1;
  35. if (mcFaultSource == FaultNoSource)
  36. {
  37. RST = 1;
  38. }
  39. }
  40. dog_Status |= 0x04;
  41. if (dog_Status >= 0x07)
  42. {
  43. dog_Status = 0;
  44. SetBit(WDT_CR, WDTRF);//喂狗 主函数、1ms中断、foc中断 三者都进
  45. }
  46. }
  47. }