Hi, I'm just curios on how this work. Is this a general C/C++ process or C51?
In main.h, I have a:
#define MAX_TIME_OUT 3000 //This is beyond U8
In Worker.c, I have Timer 2 ISR:
#include "main.h" U8 _temp_cntr; //unsigned char and not initialized //T2 init here void T2_ISR() interrupt using 0 { //some flag being set here _temp_cntr++; //Should this be back to 0 when reach 255? if(_temp_cntr == MAX_TIME_OUT) //What will happen here? { _temp_cntr = 0; } }
Hope somebody can enlighten me on this. My UART1 on F387 mcu won't able to run when Timer 2 ISR is enabled because of the specific condition under the ISR.
thanks gp
" if(_temp_cntr == MAX_TIME_OUT) //What will happen here?"
it will simple give promote both types to integer and then perform the comparison which will never be true.
but actual compilers may not perform always as expected by the rules.
?
If code below is missing, it would cause timer 2 interrupts non-stop affecting system operation: TF2 = 0;
Also, it could be a good idea to declare the variable as volatile if it is also accessed in the main program.
View all questions in Keil forum