AnsweredAssumed Answered

stm8l adc

Question asked by dion tan on Aug 31, 2017
Latest reply on Sep 7, 2017 by dion tan

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_DeInit(ADC1); 
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_Cmd(ADC1, ENABLE); 
ADC_ExternalTrigConfig(ADC1, ADC_ExtEventSelection_None, ADC_ExtTRGSensitivity_All);
ADC_SoftwareStartConv(ADC1); 
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC)); 
battery = ADC_GetConversionValue(ADC1); 

 

My lcd keep giving me 4095, which is (2^12) -1. 

Outcomes