Hi guys, may some expert please help me? I am new to stm8l. I am currently using the chip stm8l151k4t6. I have connected battery voltage to pin D7, purpose of it is that i wanna monitor the status of the battery while the device is ON. However, my Lcd display keep giving me same value(4095). Where did my code goes wrong ? below are my codes.
ADC_SamplingTimeConfig(ADC1, ADC_Group_SlowChannels, ADC_SamplingTime_4Cycles);
ADC_SchmittTriggerConfig(ADC1, ADC_Channel_7, DISABLE);
ADC_ChannelCmd(ADC1, ADC_Channel_7, ENABLE);
ADC_Init(ADC1, ADC_ConversionMode_Continuous, ADC_Resolution_12Bit, ADC_Prescaler_1);
ADC_ExternalTrigConfig(ADC1, ADC_ExtEventSelection_None, ADC_ExtTRGSensitivity_All);
battery = ADC_GetConversionValue(ADC1);
My lcd keep giving me 4095, which is (2^12) -1.