We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
relying on more than one bit in a condition is a good thing. Have you noticed the problem here?
if(Alaram=0xA5)
surely you meant
if(Alaram==0xA5)
yes?