Hello!
I'm a little bit surprised about what you write. That would be against C rules.
I don't have CCS4 anymore and therefore cannot verify, but here is what I tried
in CCS5.
Code:
loat a, b;
char * aptr, * bptr;
int i;
// Initialization
a = 1.2345;
b = 0;
aptr = (char *)(&a); // Assign a char * to float variable a
bptr = (char *)(&b); // Assign a char * to float variable b
// Copy b pointer to a pointer
for(i = 0 ; i < 4 ; ++i) {
bptr[i] = aptr[i]
}
Set a breakpoint, and progress step by step. You will notice by looking at a and
b values in the CCS debugger, that there is no problem at all in casting a float
value as a char* array. In the for loop, observe the value of b. It will take various
values and ending with the same value as a.
By the way, using char or unsigned char doesn't matter.
Now, something a little bit out of scope, but generally float values should be avoided
if they are not native to one environment.
I'm aware that in some cases (e.g. IIR filters), using a few floats can save you a lot
of headaches, but usually everything can be done using integers from ADC (which yields
integers) to output. Everything is discrete, and doing floating point operation on
an MSP430 costs really a lot of computation cycles (if I remember correctly, a simple
floating point multiplication takes more than 300 clock cycles).
You might consider fixed point operation that are possible with the hardware multiplier
and which are extremely fast.
Dora.