Obviously there are some errors in your program. (1) Please look at the default value of REFCTL0, REFMSTR=1 and REFVSEL=0. So, REFOUT is controlled by ADC module and REF voltage = 1.5V. You have to set REFCTL0 = REFVSEL_2|REFOUT|REFON. Don't use "|=". (2) Don't use "float Batt" and compare it with bits. You should use "int Batt" to compare it with 0x0001. I don't check CBCTLx settings yet. But you should fix the above two issues and try again.
↧