i show a example basic the problem in this code
i charge a char vector with values.
then i want to find the 4 bytes of float number from posicion 3
i use the number 34.5 float that is 42 0A 00 00 in ieee format
when simulete the variable valor= 0A 00 00 01 this incorret i hope (42 0A 00 00)
but the value pointer (pun_flota) if show corret 42 0A 00 00 please fix that. the corret float charge value
i attachamment the picture of register value(dspic variables.jpg)
this the code:
Code: Select all
char trama[20];
float *pun_flota,valor;
//float 34.5 = float 32 microchip 42 0A 00 00
void main()
{
trama[0]=0x01;
trama[1]=0x01;
trama[2]=0x01;
trama[3]=0x00;
trama[4]=0x00;
trama[5]=0x0A;
trama[6]=0x42;
trama[7]=0x00;
trama[8]=0x01;
pun_flota=&TRAMA[3];
valor=*pun_flota;
}
Code: Select all
char trama[20];
float *pun_flota,valor;
//float 34.5 = float 32 microchip 84 0A 00 00
void main()
{
trama[0]=0x01;
trama[1]=0x01;
trama[2]=0x01;
trama[3]=0x00;
trama[4]=0x00;
trama[5]=0x0A;
trama[6]=0x84;
trama[7]=0x00;
trama[8]=0x01;
pun_flota=&TRAMA[3];
valor=*pun_flota;
}
ok when simulet wrk ok the variable valor=84 0A 00 00 that it the correct float and the pointer pul_float= 84 0A 00 00 too
i shoe this in the pic ok.jpg file send to you
the problem with float pointer is in mikroc for dspic.
please fix this.
kind regards
Alcides Ramos