你可以使用 C 语言的定时器库来替代 PWM 模块。下面是一个示例:
#include <stdio.h>
#include <time.h>
#include <signal.h>
// 设置定时时间为 1 秒
#define INTERVAL_SEC 1
void timer_handler(int signo) {
static int count = 0;
printf("timer expired %d times\n", ++count);
}
int main() {
struct sigaction sa;
struct iti