您好,如題有一個變數 Var;一個中斷,一個main,發現此變數再中斷修改Bit1=1時,有機會被main()的舊暫存器覆蓋為0,已使用volatile,請問如何解決?
typedef union
{
unsigned char all;
struct
{
Uint16 Bit0;
Uint16 Bit1;
...
};
} Var_type;
volatile Var_type Var;
main()
{
while(1)
{
Var.Bit0=0;
}
}
__interrupt void cpu_timer0_isr(void)
{
...
Var.Bit1=1;
...
}