STM32單片機可以通過以下代碼實現重啟(core_cm3.h)。同時如果利用AT命令進行無線通訊,服務器后台和客戶端之間用MODBUS通訊即4G+MODBUS RTU,可以利用F05寫單個線圈的方法結合軟件重啟實現遠程MCU重啟

if (IO_OUT0) { delay_ms(100); __set_FAULTMASK(1); NVIC_SystemReset(); //關閉所有中斷,系統復位; } __STATIC_INLINE void NVIC_SystemReset(void) { __DSB(); /* Ensure all outstanding memory accesses included buffered write are completed before reset */ SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) | (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | SCB_AIRCR_SYSRESETREQ_Msk); /* Keep priority group unchanged */ __DSB(); /* Ensure completion of memory access */ while(1); /* wait until reset */ }