- Sun Feb 17, 2013 8:30 pm
#155733
I’m learning MCU programming with Atmega32 & winavr. I need to convert ADC value to something else (say voltage=5*ADCvalue/1023) which needs to deal with floating point/double. Then to display on LCD I need to convert the calculated value to string/array (eg. Sprintf(….)). Both these (floating point number & print function) consumes large memory/code area of the microcontroller (even with the small versions made for MCU).
Can any one please help me with any alternative way. I goggled a lot but failed to figure out solution specific to my case (I’m not an expert in programming/MCU).
*****
ISR(ADC_vect)
{
uint8_t thelow=ADCL;
uint16_t adc10bit=ADCH<<2 |thelow>>6;
float adcvolt=4.8*((adc10bit)/1023);
char adcvoltstr[10];
sprintf(adcvoltstr,"%.2f",adcvolt); //sprintf() may not be used
PrintValuetolcd(adcvolt,2,1); // display ADC value(user function)
PrintStringtolcd(adcvoltstr); //display volt (user function)
_delay_ms(50);
ADCSRA |=1<<ADSC; //start the next conversion
}
Can any one please help me with any alternative way. I goggled a lot but failed to figure out solution specific to my case (I’m not an expert in programming/MCU).
*****
ISR(ADC_vect)
{
uint8_t thelow=ADCL;
uint16_t adc10bit=ADCH<<2 |thelow>>6;
float adcvolt=4.8*((adc10bit)/1023);
char adcvoltstr[10];
sprintf(adcvoltstr,"%.2f",adcvolt); //sprintf() may not be used
PrintValuetolcd(adcvolt,2,1); // display ADC value(user function)
PrintStringtolcd(adcvoltstr); //display volt (user function)
_delay_ms(50);
ADCSRA |=1<<ADSC; //start the next conversion
}