View previous topic :: View next topic |
Author |
Message |
YulL
Joined: 29 Sep 2004 Posts: 39 Location: Paris (France)
|
Help with union |
Posted: Tue Oct 19, 2004 2:24 am |
|
|
Hi, I'm trying to send 0x100001C0C0 on the serial port. I've made a code but I have errors...
union dblock { int8 SABM[5]; } octet;
int8 count;
octet.SABM=0x100001C0C0L;
for ( count=0;count<5;count++ ) { putc( octet.SABM[count] ); }
If you have any idea...
Thanks by advance |
|
|
dvsoft
Joined: 28 Nov 2003 Posts: 46
|
|
Posted: Tue Oct 19, 2004 4:18 am |
|
|
bonjour
this code
union dblock { int8 SABM[5]; } octet;
octet.SABM=0x100001C0C0L
is not Valide
union for one int32
union {
int32 Reg;
int8 Map[4];
}TU32Reg;
TU32Reg Test;
int8 ByteCnt;
Test.Reg = 0xFF00FF00;
ByteCnt = 0;
do {
putc(Test.Map[ByteCnt]);
} while (++ByteCnt < 5);
But the Value 0x100001C0C0 is > to int32
0x100001C0C0 = 4294974476
int32
0xFFFFFFFF = 4294967295
Alain |
|
|
dvsoft
Joined: 28 Nov 2003 Posts: 46
|
|
Posted: Tue Oct 19, 2004 4:19 am |
|
|
sorry
Correct end loop
while (++ByteCnt < 4);
Alain |
|
|
YulL
Joined: 29 Sep 2004 Posts: 39 Location: Paris (France)
|
|
Posted: Tue Oct 19, 2004 7:17 am |
|
|
Ok thanks you dvsoft, but I think it should be also possible with pointers, what do you think about it? |
|
|
dvsoft
Joined: 28 Nov 2003 Posts: 46
|
|
Posted: Tue Oct 19, 2004 8:06 am |
|
|
re,
yes it is possible, with pointers. but I do not think that it is faster
Alain |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Oct 19, 2004 8:22 am |
|
|
Quote: | yes it is possible, with pointers. but I do not think that it is faster
|
It should be. That is what the FSR's are for. |
|
|
|