This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems with the variables drive.

I am begineer with this microcontroller (C167) or system embeded and i had have some problems with my program when i run this directy on the hardware.
The problem is that i can't use float numbers in my microcontroller but i don't known if is because the microcontroller or software don't support this or I have driving bad the memory models of micro.

In the program happen the next.


unsigned char CODEC (unsigned char num) { //code of decimal to ACSII
switch (num){
//here pass of digid number to ASCII code
}
retuned(num);
}


void main (void){
// setting the Variables
unsigned char datos=0;
unsigned int b=0, resultado=0;
unsigned int a=0;
float valor=0;
.... . . .
.
part of program no interesting
.

.
////END LCD CARACTERES.
while(1){
wait(900);
P7 = 0x01; // Registro Display clear.
//clean display lcd(Limpia la pantalla).
Activar(0); // 0 if is register and
//1 if is Date.
resultado = ADC_read (0); /* Get the converted value */
valor = resultado*VREF*.0009775;
//(1/1023)=.0009775 step cuantifiqued.

a = floor(valor)
P7 = CODEC(a);
//printf("valor entero= %d,valor real = %f V\r", P7, valor);
Activar(1); // 0 SI ES REGISTRO Y 1 SI ES DATO.
...... . . . .
.
.
}//end while and end the program.

In debugged this code runs good in the two modes with monitor and simulate. But in the microcontroller don't run good appear E that in may table of convert is Error and this only happen if the number is > 9.

But if puts in this same code the next runs good in the microcontroller.

//valor = resultado*VREF*.0009775;
//(1/1023)=.0009775 step cuantifiqued.
valor=3.4261;//for example

a = floor(valor)
P7 = CODEC(a);
//printf("valor entero= %d,valor real = %f V\r", P7, valor);
Activar(1); // this funtion puts on display the number.

Please somebody help me, and sorry for my inglish if something is no clear please send me a e-mail to oliver_g_t@hotmail.com

0