嵌入式开发
C语言
#include<stdio.h>
#include<cstdio>
volatile unsigned int TimeOut ;
unsigned int cnt = 0;
//使用volatile变量情景:
//1、中断
//2、多线程
//3、寄存器
void isr_handle(int a)
{
cnt++;
if (cnt > 100)
{
TimeOut = 1;
cnt = 0;
printf("cnt = %d\n", cnt);
}
printf("123 cnt = %d\n", cnt);
}
extern unsigned int TimeOut;
int main(int argc, char *argv[])
{
while (TimeOut != 1)
{
printf("hello\n");
}
return 0;
}