This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28377S: 中斷共用變數union的Bit被覆蓋問題

Part Number: TMS320F28377S


您好,如題有一個變數 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;

...

}