Yes, it would return false and so it would not wait for the ADC to complete. A way to avoid this is to do while(0==ADIF); as this will only compile with double equals.
Thanks guys. I'm using Hi-Tech C Compiler and the most recent code with while(ADIF = 0) compiled with no warnings, however it didn't function as you guys showed.
I guess another reason to look into different compilers.
I completely understand. Thanks. I only say that because I have heard a few negative comments about Hi-Tech around here, and since the above couple posts mentioned that it shouldn't even compile, when in fact it does and gives no warning. But then again maybe I need to be a little more careful.
while(ADIF = 0) is no more wrong than while(0) or while(1) is. C is a very flexible and powerful language which is why it is so easy to get into trouble with it. A good compiler will give you a warning that while(0) does nothing.
while(ADIF == 0){ //wait for ADC to finish
_delay(1);
}
When I do this command the program just waits for the ADC to finish and the interrupt flag to be set. I'm wondering, is there is a better way to accomplish this so that when the interrupt flag is set it will jump to certain code? This way I can be doing other functions while waiting for the ADC to complete.
You can setup interrupts to handle the conversion but it's really not worth it as the conversion time is only 25uS. You can do 40,000 conversions per second so unless you are really pushing the chip it is best just waiting.