hi
i have a problem with my PIC18f4550
the simulator result is as required
but the hardware isn't
the result on PORTB is exactly as simulator
i tried to assign the variable a to PORTB but it didn't work
it works as follows
but i need to get the result from equation
the same for PORTD

i have a problem with my PIC18f4550
the simulator result is as required
but the hardware isn't
Code:
float r ;
float temp;
float P_R[3] = {-17,7,10};
ADCON1 = 0xFF;
TRISD = 0x00;
TRISB = 0x00;
temp = (1.4+P_R[0])/30;
r = pow( 10,temp );
r = 1/r;
a = (unsigned short) r; //a = 3
b = (unsigned short)((r-a)*10); //b = 3
PORTB = 5;
PORTD = b;
the result on PORTB is exactly as simulator
i tried to assign the variable a to PORTB but it didn't work
it works as follows
Code:
a = 3;
PORTB = a;
the same for PORTD