CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Help with union

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
YulL



Joined: 29 Sep 2004
Posts: 39
Location: Paris (France)

View user's profile Send private message

Help with union
PostPosted: Tue Oct 19, 2004 2:24 am     Reply with quote

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... Embarassed

Thanks by advance
dvsoft



Joined: 28 Nov 2003
Posts: 46

View user's profile Send private message

PostPosted: Tue Oct 19, 2004 4:18 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Oct 19, 2004 4:19 am     Reply with quote

sorry

Correct end loop

while (++ByteCnt < 4);
Alain
YulL



Joined: 29 Sep 2004
Posts: 39
Location: Paris (France)

View user's profile Send private message

PostPosted: Tue Oct 19, 2004 7:17 am     Reply with quote

Ok thanks you dvsoft, but I think it should be also possible with pointers, what do you think about it? Rolling Eyes
dvsoft



Joined: 28 Nov 2003
Posts: 46

View user's profile Send private message

PostPosted: Tue Oct 19, 2004 8:06 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Tue Oct 19, 2004 8:22 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group