my codes:
unsigned int i=0; void Timer(void) interrupt 1 { i++; } void Main (void) { while (1) printf ("i=%d\n", i); }
To be completely correct, you should also declare i as "volatile", as it might be updated by something (the ISR) without the knowledge of the code generator / optimizer. The volatile declaration will force the compiler to actually read i, rather than using a previous and possibly stale value.