Hello guys,
I need to read the voltage from ADC pin where I have connected a voltage divider to it. I do have a code of ATMEGA where I need to convert it to HAL STM code. Can anyone please help?
Here's the code:
byte ATR[8] = {0x3B, 0x06, 0x55, 0x63, 0x63, 0x3D, 0x00, 0x00 }; //TS, T0, Historical Characters: Vcc= byte (ADCH, ADCL)
void readVcc(byte ATR[])
{
ADCSRA |= _BV(ADSC); // Convert
while (bit_is_set(ADCSRA,ADSC));
ATR[7] = ADCL; // must read ADCL first - it then locks ADCH
ATR[6] = ADCH;
}
I need to read the voltage from ADC pin where I have connected a voltage divider to it. I do have a code of ATMEGA where I need to convert it to HAL STM code. Can anyone please help?
Here's the code:
byte ATR[8] = {0x3B, 0x06, 0x55, 0x63, 0x63, 0x3D, 0x00, 0x00 }; //TS, T0, Historical Characters: Vcc= byte (ADCH, ADCL)
void readVcc(byte ATR[])
{
ADCSRA |= _BV(ADSC); // Convert
while (bit_is_set(ADCSRA,ADSC));
ATR[7] = ADCL; // must read ADCL first - it then locks ADCH
ATR[6] = ADCH;
}