| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /**
- @copyright None
- @file main.c
- @author Comment Vivre
- @date 2025-10-31
- @brief 主函数 主循环
- */
- #include <Myproject.h>
- /**
- @function main
- @brief 主函数 电机驱动主循环 任务循环
- @date 2025-10-31
- */
- void main(void)
- {
- HardwareInit();
- SoftwareInit();
- EA = 1;
- _nop_(); _nop_(); _nop_();
- WatchDogConfig(600, Enable);
-
- while (1)
- {
- if (flag_1ms_main == 1)
- {
- main_ms();
- flag_1ms_main = 0;
- }
-
- GetCurrentOffset();
- MC_Control(); // 压机主控函数,状态扫描 2.6k
- User_Dri_main(); //用户使用主函数
-
- //ptc母线继电器1s后动作
- if (Time.PowerOnCnt >= 5000)
- {
- PTC_RELAY = 1;
-
- if (mcFaultSource == FaultNoSource)
- {
- RST = 1;
- }
- }
-
- dog_Status |= 0x04;
-
- if (dog_Status >= 0x07)
- {
- dog_Status = 0;
- SetBit(WDT_CR, WDTRF);//喂狗 主函数、1ms中断、foc中断 三者都进
- }
- }
- }
|