How to protect a global variable shared by isr and regular function?

前端 未结 4 1592
星月不相逢
星月不相逢 2020-12-16 04:04

Let\'s say I have function 1 and an isr routine, both share and update the same flag without any lock between them. the system is single th

4条回答
  •  借酒劲吻你
    2020-12-16 04:54

    It will be better if you can declare the flag as : volatile int flag; or volatile bool flag;

提交回复
热议问题