veioloko
Member level 1
Hello everybody
I´m trying to convert an 24bits from a/d and display it into an lcd.
First i´m converting de 24bits to decimal, and after i add 0x30(ascii)..
however i´m having a problem
the value on the display sometimes it´s incorret, not number. it happens only where i will place X
000yxx00,
When y>=4 xx has character that is not a number.
Does anyone knows why?
I´m trying to convert an 24bits from a/d and display it into an lcd.
First i´m converting de 24bits to decimal, and after i add 0x30(ascii)..
however i´m having a problem
the value on the display sometimes it´s incorret, not number. it happens only where i will place X
000yxx00,
When y>=4 xx has character that is not a number.
Does anyone knows why?
Code:
char int_ascii(unsigned long int x){
unsigned char a, valor[8],cBuff[17];
unsigned long int var_aux;
valor[8]='\0';
valor[0] = x / 10000000; //atribui o valor ASCII a dezena de milhar
var_aux = x - (valor[0] * 10000000) ;
valor[0]= valor[0]+'0';
valor[1] = var_aux / 1000000; //atribui o valor ASCII a milhar
var_aux -= valor[1] * 1000000;
valor[1]= valor[1]+'0';
valor[2] = var_aux / 100000; //atribui o valor ASCII a milhar
var_aux -= valor[2] * 100000;
valor[2]= valor[2]+'0';
valor[3] = var_aux / 10000; //atribui o valor ASCII a milhar
var_aux -= valor[3] * 10000;
valor[3]= valor[3]+'0';
valor[4] = var_aux / 1000; //atribui o valor ASCII a milhar
var_aux -= valor[4] * 1000;
valor[4]= valor[4]+'0';
valor[5] = var_aux / 100; //atribui o valor ASCII a centena
var_aux -= valor[5] * 100;
valor[5]= valor[5]+'0';
valor[6] = var_aux / 10; //atribui o valor ASCII a dezena
var_aux -= valor[6]* 10;
valor[6]= valor[6]+'0';
valor[7] = var_aux % 10 + '0'; //atribui o valor ASCII a unidade
return ((unsigned char)valor);
}
Code:
while(!(AIPOL&0x20)) {} // Wait for conversion
result=unipolar(); // Save Results
sprintf(cBuff,"Med: %s",int_ascii(result));
lcd_env_inst(0X80);
lcd_puts(cBuff);
}