This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using Bit variable in saftey critical application

Hi, I have doubt regarding bit fields in Keil C. Suppose I am having variable alaram:

bit Alaram=0;

Alaram=P0^1;

if(Alaram==1)
{
 produceAlaram();
}


whether there is any chance of bit toggling in the software....
whether the alaram bit will changed to 1 even the P0^1 is 0...is there any possiblility?

so I change the code as.

unsigned char Alrm=P0^1;

if(Alrm)
{
 Alaram=0xA5;
}
else
{
 Alaram=0xAA;
}
if(Alaram=0xA5)
{
 produceAlaram();
}


Alaram is changed to unsigned char so one bit change cant produce alarm erroneously...whether this approach is correct...if any mistake kindly tell me and give me some guidelines for programming safety critical application........

with regards,
G.Karthik Ragunath

0