excelent! this is what worked the best, thanks a lot!
you too kef
one last question, optional tho
i need to show this converted value on a 2x16 LCD
after your answer i came up with this
void hex2dec(unsigned int hex, char *dec)
{
unsigned int temp=0;
if (hex==0) {
*dec = '0';
return;
}
while(hex!=0){
temp=hex%10; // <------------this...
*dec = (char) temp + '0';
hex=hex/10; // <------------and this are gonna take a lot of time to get done, won't they? and they require a lot of code, aren't they?
dec--;
}
}
void main(){
/*somewhere in the main*/
ADC1_Measure(1);
ADC1_GetValue8(ADCReadBuffer);
ADCm=ADCReadBuffer[0];
Voltage=(unsigned int)ADCm*130/51;
strcpy(blaf, "ADC: 0x , V");
hex2ascii((int)ADCm, banner+10);
hex2dec(Voltage, banner+15);
LCD_clear();
LCD_sendString(banner);
/*way more code*/
}
but before that i had this
unsigned char HVBm[][4] = {
/*all (255) equivalent values in asacii for ADC measures*/ //<------- 1 k of memory gone
}
void main (){
/*somewhere in the main*/
ADC1_Measure(1);
ADC1_GetValue8(ADCReadBuffer);
strcpy(blaf, "ADC: 0x , "+ 0 );
hex2ascii((int)ADCm, blaf+10);
LCD_clear();
LCD_sendString(blaf);
LCD_sendString(HVBm[ADCm]);
LCD_sendChar("V");
//code code code
}
which approach would be better? in the end both present the info the way i want it
but i'm limited in
- memory (i wouldn't like to have an array using a whole 1K just for this),
- program size (i cant make the code too large, c code may appear short but asm might get wild)
- execution time (there's a lot to do and so little time... this is a design requirement)
i think my highst priority is execution time
what do you think?