EmbeddedRelated.com
Forums

Union/type help..

Started by Micah Stevens January 16, 2005
We've never met, but I've seen Pauls picture, he's
definitely younger 
and prettier than I am. I'm a die hard assembler fan, Pauls a compiler 
writer/vendor, lot's of room there for friendly banter. ;?}

Al

Micah Stevens wrote:
> 
> Wow.. you guys seem to have some history together.. ;-) 
> 
> On Sunday 16 January 2005 05:37 pm, onestone wrote:
> 
>> Yes it can, but I've never tried it in C, I tried it a while ago,
but
>> decided on a different tack in the end.
>>
>> 25% by a seasoned programmer! and you call that efficient? Damn you
>> should use a little hot paprika and chilli instead of salt and vinegar.
>> Now that's seasoned!
>>
>> Al
>>
>> Paul Curtis wrote:
>> > Then consider this a lesson.  ;-)
>> >
>> > Are you sure that the MSP430 can do u-law or a-law conversion in
real
>> > time?  I'm not convinced, but have no numbers to back it up.
>> >
>> > Regards,
>> >
>> > --
>> > Paul Curtis, Rowley Associates Ltd  http://www.rowley.co.uk
>> > CrossWorks for MSP430, ARM, and now AVR processors  
>> >
>> >>-----Original Message-----
>> >>From: Micah Stevens [mailto:micah@mica...]
>> >>Sent: 17 January 2005 00:57
>> >>To: msp430@msp4...
>> >>Subject: Re: [msp430] Union/type help..
>> >>
>> >>
>> >>Hey! I represent that!
>> >>
>> >>On Sunday 16 January 2005 04:47 pm, Paul Curtis wrote:
>> >>> Yeah, but at least that's 25% wastage by a seasoned
>> >>
>> >>programmer.  You 
>> >>
>> >>>should see what wastage you get from newbies.  ;-)
>> >>>
>> >>> > -----Original Message-----
>> >>> > From: onestone [mailto:onestone@ones...]  > Sent:
>> >>
>> >>16 January
>> >>
>> >>>2005 21:29  > To: msp430@msp4...  > Subject: Re:
[msp430]
>> >>>Union/type help..
>> >>>
>> >>> > 25% wasted storage for 1 variable though ;@}  > 
> Al  >  > Paul
>> >>>
>> >>>Curtis wrote:
>> >>> > > // Send two 12-bit samples x and y packed into
24 bits.
>> >>> > > void send_two_samples(unsigned x, unsigned y) {
>> >>> > >   unsigned long data = ((unsigned long)x
<< 12) + y;
>> >>> > >   spi_write(&data, 3);  // assumes
little-endian addressing
>> >>> >
>> >>> > of MSP430
>> >>> >
>> >>> > > }
>> >>> > >
>> >>> > > Simple.  Forget bitfields.  C isn't that
crippled.
>> >>> > >
>> >>> > > --
>> >>> > > Paul Curtis, Rowley Associates Ltd 
>> >>
>> >>http://www.rowley.co.uk  >  >
>> >>
>> >>>CrossWorks  >  > > for MSP430, ARM, and now AVR
processors  > >  >
>> >>>
>> >>>>>-----Original Message-----  > >>From:
onestone
>> >>>
>> >>>[mailto:onestone@ones...]  > >>Sent: 16 January
2005
>> >>
>> >>21:15  >
>> >>
>> >>>>>To: msp430@msp4...  > >>Subject: Re:
[msp430] Union/type
>> >>>
>> >>>help..
>> >>>
>> >>> > >>Oh the joys of asm toys ;@}
>> >>> > >>
>> >>> > >>Al
>> >>> > >>
>> >>> > >>Georg Ritter wrote:
>> >>> > >>>microbit wrote:
>> >>> > >>>>Hi Micah,
>> >>> > >>>>
>> >>> > >>>>Weather still bad up there I here.
>> >>> > >>>>
>> >>> > >>>>>Only I'm not sure how to
define the adc/spi types.
>> >>
>> >>Is  > >>  >
>> >>
>> >>>>>there a way to  > >>  >
>>>>>define a data type with an arbitrary
>> >>>
>> >>>number of bits in  >  > it? I can't  >  >
>>>>>find any way
>> >>
>> >>to do this
>> >>
>> >>>in my searching.
>> >>>
>> >>> > >>>>>I need a 12 bit type, and an 8
bit type. Actually, 8 bit is
>> >>>
>> >>>easy  > >>>>>enough, that's a char..
>> >>>
>> >>> > >>>>Doing it that way you'd need
bitfields, I'd say - some
>> >>>
>> >>>compilers  > >>>>handle unsigned bitfields
actually quite
>> >>
>> >>well, say, bitfield [6].
>> >>
>> >>> > >>>>The only other way is to shift around
of course...
>> >>> > >>>>
>> >>> > >>>>No need of course to make sure you
don't change
>> >>
>> >>compiler in  >
>> >>
>> >>>>> > >>a hurry,  > >>  >
>>>>or set it configurable. I;m
>> >>
>> >>no expert,
>> >>
>> >>>but AFAIK Bitorder  > >>  > >>of
bitfields  > >>  > >>>>is not
>> >>>guaranteed to overlay in any specifc consistent  >  >
way
>> >>
>> >>between  > 
>> >>
>> >>>>>>>>MCUs ot maybe even different compile
settings. Never
>> >>
>> >>really  >
>> >>
>> >>>>> > >>tried that enough.
>> >>> > >>>
>> >>> > >>>Yepp I agree, you can do it, but it is
not portable
>> >>
>> >>and  > >>  >
>> >>
>> >>>>>platform and  > >>  >
>>>compiler depended, so you must
>> >>
>> >>be aware and
>> >>
>> >>>check the  > >>  > >>compiler output 
> >>  > >>>everytime things
>> >>>change. I'm still looking for a nice way  >
>>  > >>to do
>> >>
>> >>it in legal
>> >>
>> >>>C.
>> >>>
>> >>> > >>>"6.7.2.1 Structure and union
specifiers" from the c  > >>  >
>> >>>>>
>> >>>>>standards it says:
>> >>> > >>>10 An implementation may allocate any
addressable
>> >>
>> >>storage  > >> 
>> >>
>> >>>>>>unit large  > >>  >
>>>enough to hold a bit-field. If
>> >>
>> >>enough space
>> >>
>> >>>remains, a  > >>  > >>bit-field that 
> >>  >
>> >>>
>> >>>>>immediately follows
>> >>>
>> >>>another bit-field in astructure shall  >  > be packed
 >  > >>>into
>> >>>adjacent bits of the same unit. If insufficient space  >
 >
>> >>
>> >>remains, 
>> >>
>> >>>> > >>>whether a bit-field that does not fit
is put into the next
>> >>>
>> >>>unit or  > >>>overlaps adjacent units is
>> >>
>> >>implementation-defined. The
>> >>
>> >>>order of  > >>>allocation of bit-fields within
a unit
>> >>
>> >>(high-order to
>> >>
>> >>>low-order or  > >>>low-order to high-order) is
>> >>
>> >>implementation-defined.
>> >>
>> >>>The  > >>  > >>alignment of the
addressable storage unit is
>> >>>unspecified.
>> >>>
>> >>> > >>>12 Each non-bit-field member of a
structure or union
>> >>
>> >>object  >
>> >>
>> >>>>> > >>is aligned  > >>  >
>>>in an implementationdefined manner
>> >>>
>> >>>appropriate to its type.
>> >>>
>> >>> > >>>There's a -fpack-struct option for
the gcc compiler.
>> >>> > >>>
>> >>> > >>>Greetz,
>> >>> > >>>
>> >>> > >>>      Georg
>> >>> > >>>
>> >>> > >>>>B rgds
>> >>> > >>>>Kris
>> >>> > >>>>
>> >>> > >>>>
>> >>> > >>>>[Non-text portions of this message
have been
>> >>
>> >>removed]  > >>>> 
>> >>
>> >>>>>>>> > >>>>  >
>>>>.
>> >>> > >>>>
>> >>> > >>>>
>> >>> > >>>>.
>> >>
>> >>.
>> >>
>> >>
>> >>.
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
> 


Beginning Microcontrollers with the MSP430

Hi Paul,

> Sure you can create an array of objects with
bitfields, but the packing
> of bitfields does not apply across elements of an array, so there is NO
> WIN in doing so.
> 
> As an example:
> 
> // Stores a single bit
> typedef struct 
> {
>   unsigned value : 1;
> } bit_t;
> 
> // An array of bits
> bit_t bits[256];
> 
> So, what do you think sizeof(bits) is? 

it's implemention dependent.

If you embed the bitfield in a standard type like uint8_t
(stdint.h is something that even a freestanding conforming implementation must
have)
sizeof(bits) is 256.
If not and although the platform does not restrict storage of single bytes, the
compiler
is not conforming and you need a conforming compiler because in 6.5.2.1 the
standard says that
E1[E2] is identical to (*((E1)+(E2))).
That's also important for macros like this one (which does not work with
the **** IAR 1.x):

// Convert a nibble into a text hex digit.
#define mc_NIBBLE_TO_TEXT(n) ("0123456789ABCDEF"[ n ])

Regards,

Rolf



And some paprika from the sound of it.. heheh.. 


On Monday 17 January 2005 01:40 am, onestone wrote:
>  We've never met, but I've seen Pauls picture, he's
definitely younger
>  and prettier than I am. I'm a die hard assembler fan, Pauls a
compiler
>  writer/vendor, lot's of room there for friendly banter. ;?}
>
>  Al
>
>  Micah Stevens wrote:
>  > Wow.. you guys seem to have some history together.. ;-)
>  >
>  > On Sunday 16 January 2005 05:37 pm, onestone wrote:
>  >> Yes it can, but I've never tried it in C, I tried it a while
ago, but
>  >> decided on a different tack in the end.
>  >>
>  >> 25% by a seasoned programmer! and you call that efficient? Damn
you
>  >> should use a little hot paprika and chilli instead of salt and
vinegar.
>  >> Now that's seasoned!
>  >>
>  >> Al
>  >>
>  >> Paul Curtis wrote:
>  >> > Then consider this a lesson. ;-)
>  >> >
>  >> > Are you sure that the MSP430 can do u-law or a-law
conversion in real
>  >> > time? I'm not convinced, but have no numbers to back
it up.
>  >> >
>  >> > Regards,
>  >> >
>  >> > --
>  >> > Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
>  >> > CrossWorks for MSP430, ARM, and now AVR processors
>  >> >
>  >> >>-----Original Message-----
>  >> >>From: Micah Stevens [mailto:micah@mica...]
>  >> >>Sent: 17 January 2005 00:57
>  >> >>To: msp430@msp4...
>  >> >>Subject: Re: [msp430] Union/type help..
>  >> >>
>  >> >>
>  >> >>Hey! I represent that!
>  >> >>
>  >> >>On Sunday 16 January 2005 04:47 pm, Paul Curtis wrote:
>  >> >>> Yeah, but at least that's 25% wastage by a
seasoned
>  >> >>
>  >> >>programmer. You
>  >> >>
>  >> >>>should see what wastage you get from newbies. ;-)
>  >> >>>
>  >> >>> > -----Original Message-----
>  >> >>> > From: onestone [mailto:onestone@ones...] >
Sent:
>  >> >>
>  >> >>16 January
>  >> >>
>  >> >>>2005 21:29 > To: msp430@msp4... > Subject:
Re: [msp430]
>  >> >>>Union/type help..
>  >> >>>
>  >> >>> > 25% wasted storage for 1 variable though ;@}
> > Al > > Paul
>  >> >>>
>  >> >>>Curtis wrote:
>  >> >>> > > // Send two 12-bit samples x and y packed
into 24 bits.
>  >> >>> > > void send_two_samples(unsigned x, unsigned
y) {
>  >> >>> > > unsigned long data = ((unsigned long)x
<< 12) + y;
>  >> >>> > > spi_write(&data, 3); // assumes
little-endian addressing
>  >> >>> >
>  >> >>> > of MSP430
>  >> >>> >
>  >> >>> > > }
>  >> >>> > >
>  >> >>> > > Simple. Forget bitfields. C isn't
that crippled.
>  >> >>> > >
>  >> >>> > > --
>  >> >>> > > Paul Curtis, Rowley Associates Ltd
>  >> >>
>  >> >>http://www.rowley.co.uk > >
>  >> >>
>  >> >>>CrossWorks > > > for MSP430, ARM, and now
AVR processors > > >
>  >> >>>
>  >> >>>>>-----Original Message----- >
>>From: onestone
>  >> >>>
>  >> >>>[mailto:onestone@ones...] > >>Sent: 16
January 2005
>  >> >>
>  >> >>21:15 >
>  >> >>
>  >> >>>>>To: msp430@msp4... > >>Subject: Re:
[msp430] Union/type
>  >> >>>
>  >> >>>help..
>  >> >>>
>  >> >>> > >>Oh the joys of asm toys ;@}
>  >> >>> > >>
>  >> >>> > >>Al
>  >> >>> > >>
>  >> >>> > >>Georg Ritter wrote:
>  >> >>> > >>>microbit wrote:
>  >> >>> > >>>>Hi Micah,
>  >> >>> > >>>>
>  >> >>> > >>>>Weather still bad up there I
here.
>  >> >>> > >>>>
>  >> >>> > >>>>>Only I'm not sure how
to define the adc/spi types.
>  >> >>
>  >> >>Is > >> >
>  >> >>
>  >> >>>>>there a way to > >> >
>>>>>define a data type with an arbitrary
>  >> >>>
>  >> >>>number of bits in > > it? I can't >
> >>>>>find any way
>  >> >>
>  >> >>to do this
>  >> >>
>  >> >>>in my searching.
>  >> >>>
>  >> >>> > >>>>>I need a 12 bit type, and
an 8 bit type. Actually, 8 bit is
>  >> >>>
>  >> >>>easy > >>>>>enough, that's a
char..
>  >> >>>
>  >> >>> > >>>>Doing it that way you'd
need bitfields, I'd say - some
>  >> >>>
>  >> >>>compilers > >>>>handle unsigned
bitfields actually quite
>  >> >>
>  >> >>well, say, bitfield [6].
>  >> >>
>  >> >>> > >>>>The only other way is to shift
around of course...
>  >> >>> > >>>>
>  >> >>> > >>>>No need of course to make sure
you don't change
>  >> >>
>  >> >>compiler in >
>  >> >>
>  >> >>>>> > >>a hurry, > >> >
>>>>or set it configurable. I;m
>  >> >>
>  >> >>no expert,
>  >> >>
>  >> >>>but AFAIK Bitorder > >> > >>of
bitfields > >> > >>>>is not
>  >> >>>guaranteed to overlay in any specifc consistent
> > way
>  >> >>
>  >> >>between >
>  >> >>
>  >> >>>>>>>>MCUs ot maybe even different
compile settings. Never
>  >> >>
>  >> >>really >
>  >> >>
>  >> >>>>> > >>tried that enough.
>  >> >>> > >>>
>  >> >>> > >>>Yepp I agree, you can do it, but it
is not portable
>  >> >>
>  >> >>and > >> >
>  >> >>
>  >> >>>>>platform and > >> >
>>>compiler depended, so you must
>  >> >>
>  >> >>be aware and
>  >> >>
>  >> >>>check the > >> > >>compiler
output > >> > >>>everytime things
>  >> >>>change. I'm still looking for a nice way >
>> > >>to do
>  >> >>
>  >> >>it in legal
>  >> >>
>  >> >>>C.
>  >> >>>
>  >> >>> > >>>"6.7.2.1 Structure and union
specifiers" from the c > >> >
>  >> >>>>>
>  >> >>>>>standards it says:
>  >> >>> > >>>10 An implementation may allocate
any addressable
>  >> >>
>  >> >>storage > >>
>  >> >>
>  >> >>>>>>unit large > >> >
>>>enough to hold a bit-field. If
>  >> >>
>  >> >>enough space
>  >> >>
>  >> >>>remains, a > >> > >>bit-field
that > >> >
>  >> >>>
>  >> >>>>>immediately follows
>  >> >>>
>  >> >>>another bit-field in astructure shall > > be
packed > > >>>into
>  >> >>>adjacent bits of the same unit. If insufficient
space > >
>  >> >>
>  >> >>remains,
>  >> >>
>  >> >>>> > >>>whether a bit-field that does
not fit is put into the next
>  >> >>>
>  >> >>>unit or > >>>overlaps adjacent units is
>  >> >>
>  >> >>implementation-defined. The
>  >> >>
>  >> >>>order of > >>>allocation of bit-fields
within a unit
>  >> >>
>  >> >>(high-order to
>  >> >>
>  >> >>>low-order or > >>>low-order to
high-order) is
>  >> >>
>  >> >>implementation-defined.
>  >> >>
>  >> >>>The > >> > >>alignment of the
addressable storage unit is
>  >> >>>unspecified.
>  >> >>>
>  >> >>> > >>>12 Each non-bit-field member of a
structure or union
>  >> >>
>  >> >>object >
>  >> >>
>  >> >>>>> > >>is aligned > >> >
>>>in an implementationdefined manner
>  >> >>>
>  >> >>>appropriate to its type.
>  >> >>>
>  >> >>> > >>>There's a -fpack-struct option
for the gcc compiler.
>  >> >>> > >>>
>  >> >>> > >>>Greetz,
>  >> >>> > >>>
>  >> >>> > >>> Georg
>  >> >>> > >>>
>  >> >>> > >>>>B rgds
>  >> >>> > >>>>Kris
>  >> >>> > >>>>
>  >> >>> > >>>>
>  >> >>> > >>>>[Non-text portions of this
message have been
>  >> >>
>  >> >>removed] > >>>>
>  >> >>
>  >> >>>>>>>> > >>>> >
>>>>.
>  >> >>> > >>>>
>  >> >>> > >>>>
>  >> >>> > >>>>.
>  >> >>
>  >> >>.
>  >> >>
>  >> >>
>  >> >>.
>  >
>  > .
>  >
>  >
>  > .

Just had one of my Under-The-Shower-Ideas.... will only work if you're
not going to process data between getting and transmitting. But look:
(Same assumptions as in my last mail!!)

int buffer;
char *transmit;

int GetADVal1 (void);
int GetADVal2 (void);
void SendByte (char x);

...

buffer = (GetADVal1() & 0x0FFF);
transmit = &buffer;
SendByte(*transmit);
buffer = ( (buffer & 0x0F00) >>8 ) & ( (GetADVal2 & 0x0FFF)
<<4 );
SendByte(*transmit++);
SendByte(*transmit);

Hope I got it right, but that's it: Get 2 12bit values and transmit 3
8bits.
Compact, fast, no memory overhead.

Peace!


Well the paprika and chilli came from Pauls reference to
'seasoned' 
programmers. Personally I prefer mine spit roasted, but raising enough 
saliva can be a problem.

Al

Micah Stevens wrote:
> And some paprika from the sound of it.. heheh.. 
> 
> 
> On Monday 17 January 2005 01:40 am, onestone wrote:
> 
>> We've never met, but I've seen Pauls picture, he's
definitely younger
>> and prettier than I am. I'm a die hard assembler fan, Pauls a
compiler
>> writer/vendor, lot's of room there for friendly banter. ;?}
>>
>> Al
>>
>> Micah Stevens wrote:
>> > Wow.. you guys seem to have some history together.. ;-)
>> >
>> > On Sunday 16 January 2005 05:37 pm, onestone wrote:
>> >> Yes it can, but I've never tried it in C, I tried it a
while ago, but
>> >> decided on a different tack in the end.
>> >>
>> >> 25% by a seasoned programmer! and you call that efficient?
Damn you
>> >> should use a little hot paprika and chilli instead of salt and
vinegar.
>> >> Now that's seasoned!
>> >>
>> >> Al
>> >>
>> >> Paul Curtis wrote:
>> >> > Then consider this a lesson.  ;-)
>> >> >
>> >> > Are you sure that the MSP430 can do u-law or a-law
conversion in real
>> >> > time?  I'm not convinced, but have no numbers to
back it up.
>> >> >
>> >> > Regards,
>> >> >
>> >> > --
>> >> > Paul Curtis, Rowley Associates Ltd 
http://www.rowley.co.uk
>> >> > CrossWorks for MSP430, ARM, and now AVR processors 
>> >> >
>> >> >>-----Original Message-----
>> >> >>From: Micah Stevens [mailto:micah@mica...]
>> >> >>Sent: 17 January 2005 00:57
>> >> >>To: msp430@msp4...
>> >> >>Subject: Re: [msp430] Union/type help..
>> >> >>
>> >> >>
>> >> >>Hey! I represent that!
>> >> >>
>> >> >>On Sunday 16 January 2005 04:47 pm, Paul Curtis wrote:
>> >> >>> Yeah, but at least that's 25% wastage by a
seasoned
>> >> >>
>> >> >>programmer.  You
>> >> >>
>> >> >>>should see what wastage you get from newbies.  ;-)
>> >> >>>
>> >> >>> > -----Original Message-----
>> >> >>> > From: onestone [mailto:onestone@ones...] 
> Sent:
>> >> >>
>> >> >>16 January
>> >> >>
>> >> >>>2005 21:29  > To: msp430@msp4...  > Subject:
Re: [msp430]
>> >> >>>Union/type help..
>> >> >>>
>> >> >>> > 25% wasted storage for 1 variable though ;@}
 >  > Al  >  > Paul
>> >> >>>
>> >> >>>Curtis wrote:
>> >> >>> > > // Send two 12-bit samples x and y
packed into 24 bits.
>> >> >>> > > void send_two_samples(unsigned x,
unsigned y) {
>> >> >>> > >   unsigned long data = ((unsigned
long)x << 12) + y;
>> >> >>> > >   spi_write(&data, 3);  // assumes
little-endian addressing
>> >> >>> >
>> >> >>> > of MSP430
>> >> >>> >
>> >> >>> > > }
>> >> >>> > >
>> >> >>> > > Simple.  Forget bitfields.  C
isn't that crippled.
>> >> >>> > >
>> >> >>> > > --
>> >> >>> > > Paul Curtis, Rowley Associates Ltd
>> >> >>
>> >> >>http://www.rowley.co.uk  >  >
>> >> >>
>> >> >>>CrossWorks  >  > > for MSP430, ARM, and
now AVR processors  > >  >
>> >> >>>
>> >> >>>>>-----Original Message-----  >
>>From: onestone
>> >> >>>
>> >> >>>[mailto:onestone@ones...]  > >>Sent: 16
January 2005
>> >> >>
>> >> >>21:15  >
>> >> >>
>> >> >>>>>To: msp430@msp4...  > >>Subject:
Re: [msp430] Union/type
>> >> >>>
>> >> >>>help..
>> >> >>>
>> >> >>> > >>Oh the joys of asm toys ;@}
>> >> >>> > >>
>> >> >>> > >>Al
>> >> >>> > >>
>> >> >>> > >>Georg Ritter wrote:
>> >> >>> > >>>microbit wrote:
>> >> >>> > >>>>Hi Micah,
>> >> >>> > >>>>
>> >> >>> > >>>>Weather still bad up there I
here.
>> >> >>> > >>>>
>> >> >>> > >>>>>Only I'm not sure
how to define the adc/spi types.
>> >> >>
>> >> >>Is  > >>  >
>> >> >>
>> >> >>>>>there a way to  > >>  >
>>>>>define a data type with an arbitrary
>> >> >>>
>> >> >>>number of bits in  >  > it? I can't 
>  > >>>>>find any way
>> >> >>
>> >> >>to do this
>> >> >>
>> >> >>>in my searching.
>> >> >>>
>> >> >>> > >>>>>I need a 12 bit type,
and an 8 bit type. Actually, 8 bit is
>> >> >>>
>> >> >>>easy  > >>>>>enough, that's
a char..
>> >> >>>
>> >> >>> > >>>>Doing it that way you'd
need bitfields, I'd say - some
>> >> >>>
>> >> >>>compilers  > >>>>handle unsigned
bitfields actually quite
>> >> >>
>> >> >>well, say, bitfield [6].
>> >> >>
>> >> >>> > >>>>The only other way is to
shift around of course...
>> >> >>> > >>>>
>> >> >>> > >>>>No need of course to make
sure you don't change
>> >> >>
>> >> >>compiler in  >
>> >> >>
>> >> >>>>> > >>a hurry,  > >> 
> >>>>or set it configurable. I;m
>> >> >>
>> >> >>no expert,
>> >> >>
>> >> >>>but AFAIK Bitorder  > >>  > >>of
bitfields  > >>  > >>>>is not
>> >> >>>guaranteed to overlay in any specifc consistent 
>  > way
>> >> >>
>> >> >>between  >
>> >> >>
>> >> >>>>>>>>MCUs ot maybe even different
compile settings. Never
>> >> >>
>> >> >>really  >
>> >> >>
>> >> >>>>> > >>tried that enough.
>> >> >>> > >>>
>> >> >>> > >>>Yepp I agree, you can do it, but
it is not portable
>> >> >>
>> >> >>and  > >>  >
>> >> >>
>> >> >>>>>platform and  > >>  >
>>>compiler depended, so you must
>> >> >>
>> >> >>be aware and
>> >> >>
>> >> >>>check the  > >>  > >>compiler
output  > >>  > >>>everytime things
>> >> >>>change. I'm still looking for a nice way 
> >>  > >>to do
>> >> >>
>> >> >>it in legal
>> >> >>
>> >> >>>C.
>> >> >>>
>> >> >>> > >>>"6.7.2.1 Structure and
union specifiers" from the c  > >>  >
>> >> >>>>>
>> >> >>>>>standards it says:
>> >> >>> > >>>10 An implementation may
allocate any addressable
>> >> >>
>> >> >>storage  > >>
>> >> >>
>> >> >>>>>>unit large  > >>  >
>>>enough to hold a bit-field. If
>> >> >>
>> >> >>enough space
>> >> >>
>> >> >>>remains, a  > >>  > >>bit-field
that  > >>  >
>> >> >>>
>> >> >>>>>immediately follows
>> >> >>>
>> >> >>>another bit-field in astructure shall  >  >
be packed  >  > >>>into
>> >> >>>adjacent bits of the same unit. If insufficient
space  >  >
>> >> >>
>> >> >>remains,
>> >> >>
>> >> >>>> > >>>whether a bit-field that
does not fit is put into the next
>> >> >>>
>> >> >>>unit or  > >>>overlaps adjacent units
is
>> >> >>
>> >> >>implementation-defined. The
>> >> >>
>> >> >>>order of  > >>>allocation of
bit-fields within a unit
>> >> >>
>> >> >>(high-order to
>> >> >>
>> >> >>>low-order or  > >>>low-order to
high-order) is
>> >> >>
>> >> >>implementation-defined.
>> >> >>
>> >> >>>The  > >>  > >>alignment of the
addressable storage unit is
>> >> >>>unspecified.
>> >> >>>
>> >> >>> > >>>12 Each non-bit-field member of
a structure or union
>> >> >>
>> >> >>object  >
>> >> >>
>> >> >>>>> > >>is aligned  > >> 
> >>>in an implementationdefined manner
>> >> >>>
>> >> >>>appropriate to its type.
>> >> >>>
>> >> >>> > >>>There's a -fpack-struct
option for the gcc compiler.
>> >> >>> > >>>
>> >> >>> > >>>Greetz,
>> >> >>> > >>>
>> >> >>> > >>>      Georg
>> >> >>> > >>>
>> >> >>> > >>>>B rgds
>> >> >>> > >>>>Kris
>> >> >>> > >>>>
>> >> >>> > >>>>
>> >> >>> > >>>>[Non-text portions of this
message have been
>> >> >>
>> >> >>removed]  > >>>>
>> >> >>
>> >> >>>>>>>> > >>>>  >
>>>>.
>> >> >>> > >>>>
>> >> >>> > >>>>
>> >> >>> > >>>>.
>> >> >>
>> >> >>.
>> >> >>
>> >> >>
>> >> >>.
>> >
>> > .
>> >
>> > 
>> > .
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
> 


Man, much to my wife's disgust, I use so much chilli it hurts.  Twice.
;-)

-- Paul. 

> -----Original Message-----
> From: onestone [mailto:onestone@ones...] 
> Sent: 17 January 2005 18:45
> To: msp430@msp4...
> Subject: Re: [msp430] Union/type help..
> 
> 
> Well the paprika and chilli came from Pauls reference to
'seasoned' 
> programmers. Personally I prefer mine spit roasted, but 
> raising enough saliva can be a problem.
> 
> Al
> 
> Micah Stevens wrote:
> > And some paprika from the sound of it.. heheh.. 
> > 
> > 
> > On Monday 17 January 2005 01:40 am, onestone wrote:
> > 
> >> We've never met, but I've seen Pauls picture, he's 
> definitely younger 
> >> and prettier than I am. I'm a die hard assembler fan, Pauls a

> >> compiler writer/vendor, lot's of room there for friendly 
> banter. ;?}
> >>
> >> Al
> >>
> >> Micah Stevens wrote:
> >> > Wow.. you guys seem to have some history together.. ;-)
> >> >
> >> > On Sunday 16 January 2005 05:37 pm, onestone wrote:
> >> >> Yes it can, but I've never tried it in C, I tried it
a 
> while ago, 
> >> >> but decided on a different tack in the end.
> >> >>
> >> >> 25% by a seasoned programmer! and you call that
efficient? Damn 
> >> >> you should use a little hot paprika and chilli instead 
> of salt and vinegar.
> >> >> Now that's seasoned!
> >> >>
> >> >> Al
> >> >>
> >> >> Paul Curtis wrote:
> >> >> > Then consider this a lesson.  ;-)
> >> >> >
> >> >> > Are you sure that the MSP430 can do u-law or a-law 
> conversion in 
> >> >> > real time?  I'm not convinced, but have no
numbers to 
> back it up.
> >> >> >
> >> >> > Regards,
> >> >> >
> >> >> > --
> >> >> > Paul Curtis, Rowley Associates Ltd 
http://www.rowley.co.uk 
> >> >> > CrossWorks for MSP430, ARM, and now AVR processors
> >> >> >
> >> >> >>-----Original Message-----
> >> >> >>From: Micah Stevens [mailto:micah@mica...]
> >> >> >>Sent: 17 January 2005 00:57
> >> >> >>To: msp430@msp4...
> >> >> >>Subject: Re: [msp430] Union/type help..
> >> >> >>
> >> >> >>
> >> >> >>Hey! I represent that!
> >> >> >>
> >> >> >>On Sunday 16 January 2005 04:47 pm, Paul Curtis
wrote:
> >> >> >>> Yeah, but at least that's 25% wastage
by a seasoned
> >> >> >>
> >> >> >>programmer.  You
> >> >> >>
> >> >> >>>should see what wastage you get from newbies.
 ;-)
> >> >> >>>
> >> >> >>> > -----Original Message-----
> >> >> >>> > From: onestone
[mailto:onestone@ones...]  > Sent:
> >> >> >>
> >> >> >>16 January
> >> >> >>
> >> >> >>>2005 21:29  > To: msp430@msp4...  >
Subject: Re: 
> >> >> >>>[msp430] Union/type help..
> >> >> >>>
> >> >> >>> > 25% wasted storage for 1 variable
though ;@}  >  
> > Al  >  > 
> >> >> >>> > Paul
> >> >> >>>
> >> >> >>>Curtis wrote:
> >> >> >>> > > // Send two 12-bit samples x and y
packed into 24 bits.
> >> >> >>> > > void send_two_samples(unsigned x,
unsigned y) {
> >> >> >>> > >   unsigned long data = ((unsigned
long)x << 12) + y;
> >> >> >>> > >   spi_write(&data, 3);  //
assumes little-endian 
> >> >> >>> > > addressing
> >> >> >>> >
> >> >> >>> > of MSP430
> >> >> >>> >
> >> >> >>> > > }
> >> >> >>> > >
> >> >> >>> > > Simple.  Forget bitfields.  C
isn't that crippled.
> >> >> >>> > >
> >> >> >>> > > --
> >> >> >>> > > Paul Curtis, Rowley Associates Ltd
> >> >> >>
> >> >> >>http://www.rowley.co.uk  >  >
> >> >> >>
> >> >> >>>CrossWorks  >  > > for MSP430, ARM,
and now AVR 
> processors  > >  
> >> >> >>>>
> >> >> >>>
> >> >> >>>>>-----Original Message-----  >
>>From: onestone
> >> >> >>>
> >> >> >>>[mailto:onestone@ones...]  > >>Sent:
16 January 2005
> >> >> >>
> >> >> >>21:15  >
> >> >> >>
> >> >> >>>>>To: msp430@msp4...  >
>>Subject: Re: [msp430] 
> >> >> >>>>>Union/type
> >> >> >>>
> >> >> >>>help..
> >> >> >>>
> >> >> >>> > >>Oh the joys of asm toys ;@}
> >> >> >>> > >>
> >> >> >>> > >>Al
> >> >> >>> > >>
> >> >> >>> > >>Georg Ritter wrote:
> >> >> >>> > >>>microbit wrote:
> >> >> >>> > >>>>Hi Micah,
> >> >> >>> > >>>>
> >> >> >>> > >>>>Weather still bad up
there I here.
> >> >> >>> > >>>>
> >> >> >>> > >>>>>Only I'm not
sure how to define the adc/spi types.
> >> >> >>
> >> >> >>Is  > >>  >
> >> >> >>
> >> >> >>>>>there a way to  > >>  >
>>>>>define a data type with an 
> >> >> >>>>>arbitrary
> >> >> >>>
> >> >> >>>number of bits in  >  > it? I
can't  >  > >>>>>find any way
> >> >> >>
> >> >> >>to do this
> >> >> >>
> >> >> >>>in my searching.
> >> >> >>>
> >> >> >>> > >>>>>I need a 12 bit
type, and an 8 bit type. Actually, 8 
> >> >> >>> > >>>>>bit is
> >> >> >>>
> >> >> >>>easy  > >>>>>enough,
that's a char..
> >> >> >>>
> >> >> >>> > >>>>Doing it that way
you'd need bitfields, I'd say - some
> >> >> >>>
> >> >> >>>compilers  > >>>>handle
unsigned bitfields actually quite
> >> >> >>
> >> >> >>well, say, bitfield [6].
> >> >> >>
> >> >> >>> > >>>>The only other way is
to shift around of course...
> >> >> >>> > >>>>
> >> >> >>> > >>>>No need of course to
make sure you don't change
> >> >> >>
> >> >> >>compiler in  >
> >> >> >>
> >> >> >>>>> > >>a hurry,  > >>
 > >>>>or set it configurable. I;m
> >> >> >>
> >> >> >>no expert,
> >> >> >>
> >> >> >>>but AFAIK Bitorder  > >>  >
>>of bitfields  > >>  > 
> >>>>is not 
> >> >> >>>guaranteed to overlay in any specifc
consistent  >  > way
> >> >> >>
> >> >> >>between  >
> >> >> >>
> >> >> >>>>>>>>MCUs ot maybe even
different compile settings. Never
> >> >> >>
> >> >> >>really  >
> >> >> >>
> >> >> >>>>> > >>tried that enough.
> >> >> >>> > >>>
> >> >> >>> > >>>Yepp I agree, you can do
it, but it is not portable
> >> >> >>
> >> >> >>and  > >>  >
> >> >> >>
> >> >> >>>>>platform and  > >>  >
>>>compiler depended, so you must
> >> >> >>
> >> >> >>be aware and
> >> >> >>
> >> >> >>>check the  > >>  >
>>compiler output  > >>  > >>>everytime 
> >> >> >>>things change. I'm still looking for a
nice way  > 
> >>  > >>to 
> >> >> >>>do
> >> >> >>
> >> >> >>it in legal
> >> >> >>
> >> >> >>>C.
> >> >> >>>
> >> >> >>> > >>>"6.7.2.1 Structure and
union specifiers" from 
> the c  > >>  
> >> >> >>> > >>>>
> >> >> >>>>>
> >> >> >>>>>standards it says:
> >> >> >>> > >>>10 An implementation may
allocate any addressable
> >> >> >>
> >> >> >>storage  > >>
> >> >> >>
> >> >> >>>>>>unit large  > >>  >
>>>enough to hold a bit-field. If
> >> >> >>
> >> >> >>enough space
> >> >> >>
> >> >> >>>remains, a  > >>  >
>>bit-field that  > >>  >
> >> >> >>>
> >> >> >>>>>immediately follows
> >> >> >>>
> >> >> >>>another bit-field in astructure shall  > 
> be packed  >  > 
> >> >> >>>>>>into adjacent bits of the same
unit. If 
> insufficient space  
> >> >> >>>>  >
> >> >> >>
> >> >> >>remains,
> >> >> >>
> >> >> >>>> > >>>whether a bit-field
that does not fit is put into the 
> >> >> >>>> > >>>next
> >> >> >>>
> >> >> >>>unit or  > >>>overlaps adjacent
units is
> >> >> >>
> >> >> >>implementation-defined. The
> >> >> >>
> >> >> >>>order of  > >>>allocation of
bit-fields within a unit
> >> >> >>
> >> >> >>(high-order to
> >> >> >>
> >> >> >>>low-order or  > >>>low-order to
high-order) is
> >> >> >>
> >> >> >>implementation-defined.
> >> >> >>
> >> >> >>>The  > >>  > >>alignment of
the addressable storage unit is 
> >> >> >>>unspecified.
> >> >> >>>
> >> >> >>> > >>>12 Each non-bit-field
member of a structure or union
> >> >> >>
> >> >> >>object  >
> >> >> >>
> >> >> >>>>> > >>is aligned  >
>>  > >>>in an implementationdefined 
> >> >> >>>>> > >>manner
> >> >> >>>
> >> >> >>>appropriate to its type.
> >> >> >>>
> >> >> >>> > >>>There's a
-fpack-struct option for the gcc compiler.
> >> >> >>> > >>>
> >> >> >>> > >>>Greetz,
> >> >> >>> > >>>
> >> >> >>> > >>>      Georg
> >> >> >>> > >>>
> >> >> >>> > >>>>B rgds
> >> >> >>> > >>>>Kris
> >> >> >>> > >>>>
> >> >> >>> > >>>>
> >> >> >>> > >>>>[Non-text portions of
this message have been
> >> >> >>
> >> >> >>removed]  > >>>>
> >> >> >>
> >> >> >>>>>>>> > >>>> 
> >>>>.
> >> >> >>> > >>>>
> >> >> >>> > >>>>
> >> >> >>> > >>>>.
> >> >> >>
> >> >> >>.
> >> >> >>
> >> >> >>
> >> >> >>.
> > 
> > 
> > 
> > .
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> > 
> > 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
> 
> 

Ahh.. that explains so much.. :) 

On Monday 17 January 2005 03:07 pm, Paul Curtis wrote:
>  Man, much to my wife's disgust, I use so much chilli it hurts.
Twice.
>  ;-)
>
>  -- Paul.
>
>  > -----Original Message-----
>  > From: onestone [mailto:onestone@ones...]
>  > Sent: 17 January 2005 18:45
>  > To: msp430@msp4...
>  > Subject: Re: [msp430] Union/type help..
>  >
>  >
>  > Well the paprika and chilli came from Pauls reference to
'seasoned'
>  > programmers. Personally I prefer mine spit roasted, but
>  > raising enough saliva can be a problem.
>  >
>  > Al
>  >
>  > Micah Stevens wrote:
>  > > And some paprika from the sound of it.. heheh..
>  > >
>  > > On Monday 17 January 2005 01:40 am, onestone wrote:
>  > >> We've never met, but I've seen Pauls picture,
he's
>  >
>  > definitely younger
>  >
>  > >> and prettier than I am. I'm a die hard assembler fan,
Pauls a
>  > >> compiler writer/vendor, lot's of room there for
friendly
>  >
>  > banter. ;?}
>  >
>  > >> Al
>  > >>
>  > >> Micah Stevens wrote:
>  > >> > Wow.. you guys seem to have some history together.. ;-)
>  > >> >
>  > >> > On Sunday 16 January 2005 05:37 pm, onestone wrote:
>  > >> >> Yes it can, but I've never tried it in C, I
tried it a
>  >
>  > while ago,
>  >
>  > >> >> but decided on a different tack in the end.
>  > >> >>
>  > >> >> 25% by a seasoned programmer! and you call that
efficient? Damn
>  > >> >> you should use a little hot paprika and chilli
instead
>  >
>  > of salt and vinegar.
>  >
>  > >> >> Now that's seasoned!
>  > >> >>
>  > >> >> Al
>  > >> >>
>  > >> >> Paul Curtis wrote:
>  > >> >> > Then consider this a lesson. ;-)
>  > >> >> >
>  > >> >> > Are you sure that the MSP430 can do u-law or
a-law
>  >
>  > conversion in
>  >
>  > >> >> > real time? I'm not convinced, but have
no numbers to
>  >
>  > back it up.
>  >
>  > >> >> > Regards,
>  > >> >> >
>  > >> >> > --
>  > >> >> > Paul Curtis, Rowley Associates Ltd
http://www.rowley.co.uk
>  > >> >> > CrossWorks for MSP430, ARM, and now AVR
processors
>  > >> >> >
>  > >> >> >>-----Original Message-----
>  > >> >> >>From: Micah Stevens [mailto:micah@mica...]
>  > >> >> >>Sent: 17 January 2005 00:57
>  > >> >> >>To: msp430@msp4...
>  > >> >> >>Subject: Re: [msp430] Union/type help..
>  > >> >> >>
>  > >> >> >>
>  > >> >> >>Hey! I represent that!
>  > >> >> >>
>  > >> >> >>On Sunday 16 January 2005 04:47 pm, Paul
Curtis wrote:
>  > >> >> >>> Yeah, but at least that's 25%
wastage by a seasoned
>  > >> >> >>
>  > >> >> >>programmer. You
>  > >> >> >>
>  > >> >> >>>should see what wastage you get from
newbies. ;-)
>  > >> >> >>>
>  > >> >> >>> > -----Original Message-----
>  > >> >> >>> > From: onestone
[mailto:onestone@ones...] > Sent:
>  > >> >> >>
>  > >> >> >>16 January
>  > >> >> >>
>  > >> >> >>>2005 21:29 > To: msp430@msp4...
> Subject: Re:
>  > >> >> >>>[msp430] Union/type help..
>  > >> >> >>>
>  > >> >> >>> > 25% wasted storage for 1 variable
though ;@} >
>  > >
>  > > Al > >
>  > >
>  > >> >> >>> > Paul
>  > >> >> >>>
>  > >> >> >>>Curtis wrote:
>  > >> >> >>> > > // Send two 12-bit samples x
and y packed into 24 bits.
>  > >> >> >>> > > void
send_two_samples(unsigned x, unsigned y) {
>  > >> >> >>> > > unsigned long data =
((unsigned long)x << 12) + y;
>  > >> >> >>> > > spi_write(&data, 3);
// assumes little-endian
>  > >> >> >>> > > addressing
>  > >> >> >>> >
>  > >> >> >>> > of MSP430
>  > >> >> >>> >
>  > >> >> >>> > > }
>  > >> >> >>> > >
>  > >> >> >>> > > Simple. Forget bitfields.
C isn't that crippled.
>  > >> >> >>> > >
>  > >> >> >>> > > --
>  > >> >> >>> > > Paul Curtis, Rowley
Associates Ltd
>  > >> >> >>
>  > >> >> >>http://www.rowley.co.uk > >
>  > >> >> >>
>  > >> >> >>>CrossWorks > > > for MSP430,
ARM, and now AVR
>  >
>  > processors > >
>  >
>  > >> >> >>>>>-----Original Message-----
> >>From: onestone
>  > >> >> >>>
>  > >> >> >>>[mailto:onestone@ones...] >
>>Sent: 16 January 2005
>  > >> >> >>
>  > >> >> >>21:15 >
>  > >> >> >>
>  > >> >> >>>>>To: msp430@msp4... >
>>Subject: Re: [msp430]
>  > >> >> >>>>>Union/type
>  > >> >> >>>
>  > >> >> >>>help..
>  > >> >> >>>
>  > >> >> >>> > >>Oh the joys of asm toys
;@}
>  > >> >> >>> > >>
>  > >> >> >>> > >>Al
>  > >> >> >>> > >>
>  > >> >> >>> > >>Georg Ritter wrote:
>  > >> >> >>> > >>>microbit wrote:
>  > >> >> >>> > >>>>Hi Micah,
>  > >> >> >>> > >>>>
>  > >> >> >>> > >>>>Weather still bad
up there I here.
>  > >> >> >>> > >>>>
>  > >> >> >>> > >>>>>Only I'm
not sure how to define the adc/spi types.
>  > >> >> >>
>  > >> >> >>Is > >> >
>  > >> >> >>
>  > >> >> >>>>>there a way to > >>
> >>>>>define a data type with an
>  > >> >> >>>>>arbitrary
>  > >> >> >>>
>  > >> >> >>>number of bits in > > it? I
can't > > >>>>>find any way
>  > >> >> >>
>  > >> >> >>to do this
>  > >> >> >>
>  > >> >> >>>in my searching.
>  > >> >> >>>
>  > >> >> >>> > >>>>>I need a 12
bit type, and an 8 bit type. Actually, 8
>  > >> >> >>> > >>>>>bit is
>  > >> >> >>>
>  > >> >> >>>easy > >>>>>enough,
that's a char..
>  > >> >> >>>
>  > >> >> >>> > >>>>Doing it that way
you'd need bitfields, I'd say - some
>  > >> >> >>>
>  > >> >> >>>compilers > >>>>handle
unsigned bitfields actually quite
>  > >> >> >>
>  > >> >> >>well, say, bitfield [6].
>  > >> >> >>
>  > >> >> >>> > >>>>The only other
way is to shift around of course...
>  > >> >> >>> > >>>>
>  > >> >> >>> > >>>>No need of course
to make sure you don't change
>  > >> >> >>
>  > >> >> >>compiler in >
>  > >> >> >>
>  > >> >> >>>>> > >>a hurry, >
>> > >>>>or set it configurable. I;m
>  > >> >> >>
>  > >> >> >>no expert,
>  > >> >> >>
>  > >> >> >>>but AFAIK Bitorder > >> >
>>of bitfields > >> >
>  > >>>>
>  > >>>>is not
>  > >>>>
>  > >> >> >>>guaranteed to overlay in any specifc
consistent > > way
>  > >> >> >>
>  > >> >> >>between >
>  > >> >> >>
>  > >> >> >>>>>>>>MCUs ot maybe even
different compile settings. Never
>  > >> >> >>
>  > >> >> >>really >
>  > >> >> >>
>  > >> >> >>>>> > >>tried that
enough.
>  > >> >> >>> > >>>
>  > >> >> >>> > >>>Yepp I agree, you can
do it, but it is not portable
>  > >> >> >>
>  > >> >> >>and > >> >
>  > >> >> >>
>  > >> >> >>>>>platform and > >>
> >>>compiler depended, so you must
>  > >> >> >>
>  > >> >> >>be aware and
>  > >> >> >>
>  > >> >> >>>check the > >> >
>>compiler output > >> > >>>everytime
>  > >> >> >>>things change. I'm still looking
for a nice way >
>  > >>
>  > >> > >>to
>  > >>
>  > >> >> >>>do
>  > >> >> >>
>  > >> >> >>it in legal
>  > >> >> >>
>  > >> >> >>>C.
>  > >> >> >>>
>  > >> >> >>> > >>>"6.7.2.1
Structure and union specifiers" from
>  >
>  > the c > >>
>  >
>  > >> >> >>>>>standards it says:
>  > >> >> >>> > >>>10 An implementation
may allocate any addressable
>  > >> >> >>
>  > >> >> >>storage > >>
>  > >> >> >>
>  > >> >> >>>>>>unit large > >>
> >>>enough to hold a bit-field. If
>  > >> >> >>
>  > >> >> >>enough space
>  > >> >> >>
>  > >> >> >>>remains, a > >> >
>>bit-field that > >> >
>  > >> >> >>>
>  > >> >> >>>>>immediately follows
>  > >> >> >>>
>  > >> >> >>>another bit-field in astructure shall
> > be packed > >
>  > >> >> >>>
>  > >> >> >>>>>>into adjacent bits of the
same unit. If
>  >
>  > insufficient space
>  >
>  > >> >> >>>> >
>  > >> >> >>
>  > >> >> >>remains,
>  > >> >> >>
>  > >> >> >>>> > >>>whether a
bit-field that does not fit is put into the
>  > >> >> >>>> > >>>next
>  > >> >> >>>
>  > >> >> >>>unit or > >>>overlaps
adjacent units is
>  > >> >> >>
>  > >> >> >>implementation-defined. The
>  > >> >> >>
>  > >> >> >>>order of > >>>allocation
of bit-fields within a unit
>  > >> >> >>
>  > >> >> >>(high-order to
>  > >> >> >>
>  > >> >> >>>low-order or >
>>>low-order to high-order) is
>  > >> >> >>
>  > >> >> >>implementation-defined.
>  > >> >> >>
>  > >> >> >>>The > >> >
>>alignment of the addressable storage unit is
>  > >> >> >>>unspecified.
>  > >> >> >>>
>  > >> >> >>> > >>>12 Each non-bit-field
member of a structure or union
>  > >> >> >>
>  > >> >> >>object >
>  > >> >> >>
>  > >> >> >>>>> > >>is aligned >
>> > >>>in an implementationdefined
>  > >> >> >>>>> > >>manner
>  > >> >> >>>
>  > >> >> >>>appropriate to its type.
>  > >> >> >>>
>  > >> >> >>> > >>>There's a
-fpack-struct option for the gcc compiler.
>  > >> >> >>> > >>>
>  > >> >> >>> > >>>Greetz,
>  > >> >> >>> > >>>
>  > >> >> >>> > >>> Georg
>  > >> >> >>> > >>>
>  > >> >> >>> > >>>>B rgds
>  > >> >> >>> > >>>>Kris
>  > >> >> >>> > >>>>
>  > >> >> >>> > >>>>
>  > >> >> >>> > >>>>[Non-text
portions of this message have been
>  > >> >> >>
>  > >> >> >>removed] > >>>>
>  > >> >> >>
>  > >> >> >>>>>>>> >
>>>> > >>>>.
>  > >> >> >>> > >>>>
>  > >> >> >>> > >>>>
>  > >> >> >>> > >>>>.
>  >
>  > >> >> >>.
>  > >> >> >>
>  > >> >> >>
>  > >> >> >>.
>  > >
>  > > .
>  > >
>  > >
>  > > .

Word. Thanks again Sepp.

I'm still running into issues with my stupid transceiver. RF is tough
stuff. 

FYI folks: The MSP WILL do ulaw encoding and decoding. (I did an on-chip 
loopback) but it seems to be REALLY noisy. At first I thought it might be 
dropping packets due to too much overhead, but looking at the stack it seemed 
already. 

Just introducing this ulaw code increased my noise floor from barely 
noticeable to so bad you could hardly hear my voice over the top. Any ideas 
why this would happen? 

The code I'm using is 16bit to 8bit ulaw, and I'm giving it 12 bit
packets, 
would that bear in? I would assume it would just make over levels lower. 

-Micah 

On Monday 17 January 2005 10:35 am, Sepp Holzmayr
wrote:
>  Just had one of my Under-The-Shower-Ideas.... will only work if
you're
>  not going to process data between getting and transmitting. But look:
>  (Same assumptions as in my last mail!!)
>
>  int buffer;
>  char *transmit;
>
>  int GetADVal1 (void);
>  int GetADVal2 (void);
>  void SendByte (char x);
>
>  ...
>
>  buffer = (GetADVal1() & 0x0FFF);
>  transmit = &buffer;
>  SendByte(*transmit);
>  buffer = ( (buffer & 0x0F00) >>8 ) & ( (GetADVal2 &
0x0FFF) <<4 );
>  SendByte(*transmit++);
>  SendByte(*transmit);
>
>  Hope I got it right, but that's it: Get 2 12bit values and transmit 3
> 8bits. Compact, fast, no memory overhead.
>
>  Peace!
>
>
>
>  .
>
>
>
>
>
>  .

I managed to resist replying to this. Every reply I visualised was just 
too far out there to contemplate.

Al

Micah Stevens wrote:

> 
> Ahh.. that explains so much.. :) 
> 
> On Monday 17 January 2005 03:07 pm, Paul Curtis wrote:
> 
>> Man, much to my wife's disgust, I use so much chilli it hurts. 
Twice.
>> ;-)
>>
>> -- Paul.
>>
>> > -----Original Message-----
>> > From: onestone [mailto:onestone@ones...]
>> > Sent: 17 January 2005 18:45
>> > To: msp430@msp4...
>> > Subject: Re: [msp430] Union/type help..
>> >
>> >
>> > Well the paprika and chilli came from Pauls reference to
'seasoned'
>> > programmers. Personally I prefer mine spit roasted, but
>> > raising enough saliva can be a problem.
>> >
>> > Al
>> >
>> > Micah Stevens wrote:
>> > > And some paprika from the sound of it.. heheh..
>> > >
>> > > On Monday 17 January 2005 01:40 am, onestone wrote:
>> > >> We've never met, but I've seen Pauls picture,
he's
>> >
>> > definitely younger
>> >
>> > >> and prettier than I am. I'm a die hard assembler
fan, Pauls a
>> > >> compiler writer/vendor, lot's of room there for
friendly
>> >
>> > banter. ;?}
>> >
>> > >> Al
>> > >>
>> > >> Micah Stevens wrote:
>> > >> > Wow.. you guys seem to have some history together..
;-)
>> > >> >
>> > >> > On Sunday 16 January 2005 05:37 pm, onestone wrote:
>> > >> >> Yes it can, but I've never tried it in C, I
tried it a
>> >
>> > while ago,
>> >
>> > >> >> but decided on a different tack in the end.
>> > >> >>
>> > >> >> 25% by a seasoned programmer! and you call that
efficient? Damn
>> > >> >> you should use a little hot paprika and chilli
instead
>> >
>> > of salt and vinegar.
>> >
>> > >> >> Now that's seasoned!
>> > >> >>
>> > >> >> Al
>> > >> >>
>> > >> >> Paul Curtis wrote:
>> > >> >> > Then consider this a lesson.  ;-)
>> > >> >> >
>> > >> >> > Are you sure that the MSP430 can do u-law
or a-law
>> >
>> > conversion in
>> >
>> > >> >> > real time?  I'm not convinced, but
have no numbers to
>> >
>> > back it up.
>> >
>> > >> >> > Regards,
>> > >> >> >
>> > >> >> > --
>> > >> >> > Paul Curtis, Rowley Associates Ltd 
http://www.rowley.co.uk
>> > >> >> > CrossWorks for MSP430, ARM, and now AVR
processors
>> > >> >> >
>> > >> >> >>-----Original Message-----
>> > >> >> >>From: Micah Stevens
[mailto:micah@mica...]
>> > >> >> >>Sent: 17 January 2005 00:57
>> > >> >> >>To: msp430@msp4...
>> > >> >> >>Subject: Re: [msp430] Union/type help..
>> > >> >> >>
>> > >> >> >>
>> > >> >> >>Hey! I represent that!
>> > >> >> >>
>> > >> >> >>On Sunday 16 January 2005 04:47 pm, Paul
Curtis wrote:
>> > >> >> >>> Yeah, but at least that's 25%
wastage by a seasoned
>> > >> >> >>
>> > >> >> >>programmer.  You
>> > >> >> >>
>> > >> >> >>>should see what wastage you get from
newbies.  ;-)
>> > >> >> >>>
>> > >> >> >>> > -----Original Message-----
>> > >> >> >>> > From: onestone
[mailto:onestone@ones...]  > Sent:
>> > >> >> >>
>> > >> >> >>16 January
>> > >> >> >>
>> > >> >> >>>2005 21:29  > To: msp430@msp4... 
> Subject: Re:
>> > >> >> >>>[msp430] Union/type help..
>> > >> >> >>>
>> > >> >> >>> > 25% wasted storage for 1
variable though ;@}  > 
>> > >
>> > > Al  >  >
>> > >
>> > >> >> >>> > Paul
>> > >> >> >>>
>> > >> >> >>>Curtis wrote:
>> > >> >> >>> > > // Send two 12-bit
samples x and y packed into 24 bits.
>> > >> >> >>> > > void
send_two_samples(unsigned x, unsigned y) {
>> > >> >> >>> > >   unsigned long data =
((unsigned long)x << 12) + y;
>> > >> >> >>> > >   spi_write(&data,
3);  // assumes little-endian
>> > >> >> >>> > > addressing
>> > >> >> >>> >
>> > >> >> >>> > of MSP430
>> > >> >> >>> >
>> > >> >> >>> > > }
>> > >> >> >>> > >
>> > >> >> >>> > > Simple.  Forget
bitfields.  C isn't that crippled.
>> > >> >> >>> > >
>> > >> >> >>> > > --
>> > >> >> >>> > > Paul Curtis, Rowley
Associates Ltd
>> > >> >> >>
>> > >> >> >>http://www.rowley.co.uk  >  >
>> > >> >> >>
>> > >> >> >>>CrossWorks  >  > > for
MSP430, ARM, and now AVR
>> >
>> > processors  > > 
>> >
>> > >> >> >>>>>-----Original Message----- 
> >>From: onestone
>> > >> >> >>>
>> > >> >> >>>[mailto:onestone@ones...]  >
>>Sent: 16 January 2005
>> > >> >> >>
>> > >> >> >>21:15  >
>> > >> >> >>
>> > >> >> >>>>>To: msp430@msp4...  >
>>Subject: Re: [msp430]
>> > >> >> >>>>>Union/type
>> > >> >> >>>
>> > >> >> >>>help..
>> > >> >> >>>
>> > >> >> >>> > >>Oh the joys of asm
toys ;@}
>> > >> >> >>> > >>
>> > >> >> >>> > >>Al
>> > >> >> >>> > >>
>> > >> >> >>> > >>Georg Ritter wrote:
>> > >> >> >>> > >>>microbit wrote:
>> > >> >> >>> > >>>>Hi Micah,
>> > >> >> >>> > >>>>
>> > >> >> >>> > >>>>Weather still
bad up there I here.
>> > >> >> >>> > >>>>
>> > >> >> >>> > >>>>>Only
I'm not sure how to define the adc/spi types.
>> > >> >> >>
>> > >> >> >>Is  > >>  >
>> > >> >> >>
>> > >> >> >>>>>there a way to  >
>>  > >>>>>define a data type with an
>> > >> >> >>>>>arbitrary
>> > >> >> >>>
>> > >> >> >>>number of bits in  >  > it? I
can't  >  > >>>>>find any way
>> > >> >> >>
>> > >> >> >>to do this
>> > >> >> >>
>> > >> >> >>>in my searching.
>> > >> >> >>>
>> > >> >> >>> > >>>>>I need a
12 bit type, and an 8 bit type. Actually, 8
>> > >> >> >>> > >>>>>bit is
>> > >> >> >>>
>> > >> >> >>>easy  >
>>>>>enough, that's a char..
>> > >> >> >>>
>> > >> >> >>> > >>>>Doing it that
way you'd need bitfields, I'd say - some
>> > >> >> >>>
>> > >> >> >>>compilers  >
>>>>handle unsigned bitfields actually quite
>> > >> >> >>
>> > >> >> >>well, say, bitfield [6].
>> > >> >> >>
>> > >> >> >>> > >>>>The only other
way is to shift around of course...
>> > >> >> >>> > >>>>
>> > >> >> >>> > >>>>No need of
course to make sure you don't change
>> > >> >> >>
>> > >> >> >>compiler in  >
>> > >> >> >>
>> > >> >> >>>>> > >>a hurry,  >
>>  > >>>>or set it configurable. I;m
>> > >> >> >>
>> > >> >> >>no expert,
>> > >> >> >>
>> > >> >> >>>but AFAIK Bitorder  > >> 
> >>of bitfields  > >>  >
>> > >>>>
>> > >>>>is not
>> > >>>>
>> > >> >> >>>guaranteed to overlay in any specifc
consistent  >  > way
>> > >> >> >>
>> > >> >> >>between  >
>> > >> >> >>
>> > >> >> >>>>>>>>MCUs ot maybe
even different compile settings. Never
>> > >> >> >>
>> > >> >> >>really  >
>> > >> >> >>
>> > >> >> >>>>> > >>tried that
enough.
>> > >> >> >>> > >>>
>> > >> >> >>> > >>>Yepp I agree, you
can do it, but it is not portable
>> > >> >> >>
>> > >> >> >>and  > >>  >
>> > >> >> >>
>> > >> >> >>>>>platform and  > >> 
> >>>compiler depended, so you must
>> > >> >> >>
>> > >> >> >>be aware and
>> > >> >> >>
>> > >> >> >>>check the  > >>  >
>>compiler output  > >>  > >>>everytime
>> > >> >> >>>things change. I'm still
looking for a nice way  >
>> > >>
>> > >>  > >>to
>> > >>
>> > >> >> >>>do
>> > >> >> >>
>> > >> >> >>it in legal
>> > >> >> >>
>> > >> >> >>>C.
>> > >> >> >>>
>> > >> >> >>> > >>>"6.7.2.1
Structure and union specifiers" from
>> >
>> > the c  > >> 
>> >
>> > >> >> >>>>>standards it says:
>> > >> >> >>> > >>>10 An
implementation may allocate any addressable
>> > >> >> >>
>> > >> >> >>storage  > >>
>> > >> >> >>
>> > >> >> >>>>>>unit large  >
>>  > >>>enough to hold a bit-field. If
>> > >> >> >>
>> > >> >> >>enough space
>> > >> >> >>
>> > >> >> >>>remains, a  > >>  >
>>bit-field that  > >>  >
>> > >> >> >>>
>> > >> >> >>>>>immediately follows
>> > >> >> >>>
>> > >> >> >>>another bit-field in astructure
shall  >  > be packed  >  >
>> > >> >> >>>
>> > >> >> >>>>>>into adjacent bits of
the same unit. If
>> >
>> > insufficient space 
>> >
>> > >> >> >>>>  >
>> > >> >> >>
>> > >> >> >>remains,
>> > >> >> >>
>> > >> >> >>>> > >>>whether a
bit-field that does not fit is put into the
>> > >> >> >>>> > >>>next
>> > >> >> >>>
>> > >> >> >>>unit or  > >>>overlaps
adjacent units is
>> > >> >> >>
>> > >> >> >>implementation-defined. The
>> > >> >> >>
>> > >> >> >>>order of  >
>>>allocation of bit-fields within a unit
>> > >> >> >>
>> > >> >> >>(high-order to
>> > >> >> >>
>> > >> >> >>>low-order or  >
>>>low-order to high-order) is
>> > >> >> >>
>> > >> >> >>implementation-defined.
>> > >> >> >>
>> > >> >> >>>The  > >>  >
>>alignment of the addressable storage unit is
>> > >> >> >>>unspecified.
>> > >> >> >>>
>> > >> >> >>> > >>>12 Each
non-bit-field member of a structure or union
>> > >> >> >>
>> > >> >> >>object  >
>> > >> >> >>
>> > >> >> >>>>> > >>is aligned 
> >>  > >>>in an implementationdefined
>> > >> >> >>>>> > >>manner
>> > >> >> >>>
>> > >> >> >>>appropriate to its type.
>> > >> >> >>>
>> > >> >> >>> > >>>There's a
-fpack-struct option for the gcc compiler.
>> > >> >> >>> > >>>
>> > >> >> >>> > >>>Greetz,
>> > >> >> >>> > >>>
>> > >> >> >>> > >>>      Georg
>> > >> >> >>> > >>>
>> > >> >> >>> > >>>>B rgds
>> > >> >> >>> > >>>>Kris
>> > >> >> >>> > >>>>
>> > >> >> >>> > >>>>
>> > >> >> >>> > >>>>[Non-text
portions of this message have been
>> > >> >> >>
>> > >> >> >>removed]  > >>>>
>> > >> >> >>
>> > >> >> >>>>>>>> >
>>>>  > >>>>.
>> > >> >> >>> > >>>>
>> > >> >> >>> > >>>>
>> > >> >> >>> > >>>>.
>> >
>> > >> >> >>.
>> > >> >> >>
>> > >> >> >>
>> > >> >> >>.
>> > >
>> > > .
>> > >
>> > > 
>> > > .
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
> 


Micah Stevens wrote:

> 
> Word.

Oh, God! No, please don't turn into another talk show refugee. My 
vocabulary comprises around 64000 words which one are you refering to?

;?{


> Thanks again Sepp.
> 
> I'm still running into issues with my stupid transceiver. RF is tough
> stuff.

Only if you are doing overly tough things with it. Kris is the real 
hardcore RF guy here. I like black box solutions. Simple devices like 
the RFM1000 are ridiculously easy to get running to meet their basic 
specs, while the nRF905 and its like are almost as easy, but far more 
flexible at a much lower price. If you want to squeeze every drop of 
performance or data rate sure it's not easy, but if you follow the 
reference designs and fairly basic design rules RF can be as easy as any 
other peripheral, like IIC/SPi etc.

> 
> FYI folks: The MSP WILL do ulaw encoding and decoding. (I did an
> on-chip loopback) but it seems to be REALLY noisy. At first I thought
> it might be dropping packets due to too much overhead, but looking at
> the stack it seemed already.
> 
> Just introducing this ulaw code increased my noise floor from barely
>  noticeable to so bad you could hardly hear my voice over the top.
> Any ideas why this would happen?
> 
> The code I'm using is 16bit to 8bit ulaw, and I'm giving it 12
bit
> packets, would that bear in? I would assume it would just make over
> levels lower.

Sorry, doesn't work that way. I'm not surprised you have noise. You
need
to tailor the algorithm to 12 bits.

It almost sounds like you've reversed encode and decode! With u/A-law 
the basic principal is that most of the information exists in the lower 
bits, the fine detail, the larger values simply represent 
volume/loudness, which your ear isn't as well attuned to. Thus, assuming 
your noise levels are low anyway (I'd look really closely at this first) 
you shouldn't increase the perceived noise by much.

Al

> 
> -Micah
> 
> On Monday 17 January 2005 10:35 am, Sepp Holzmayr wrote:
> 
>> Just had one of my Under-The-Shower-Ideas.... will only work if
>> you're not going to process data between getting and transmitting.
>> But look: (Same assumptions as in my last mail!!)
>> 
>> int buffer; char *transmit;
>> 
>> int GetADVal1 (void); int GetADVal2 (void); void SendByte (char x);
>> 
>> 
>> ...
>> 
>> buffer = (GetADVal1() & 0x0FFF); transmit = &buffer; 
>> SendByte(*transmit); buffer = ( (buffer & 0x0F00) >>8 ) &
(
>> (GetADVal2 & 0x0FFF) <<4 ); SendByte(*transmit++); 
>> SendByte(*transmit);
>> 
>> Hope I got it right, but that's it: Get 2 12bit values and
transmit
>> 3 8bits. Compact, fast, no memory overhead.
>> 
>> Peace!
>> 
>> 
>> 
>> .
>> 
>> 
>> 
>> 
>> 
>> Yahoo! Groups Links
>> 
>> To visit your group on the web, go to: 
>> http://groups.yahoo.com/group/msp430/
>> 
>> .
>> 
>> Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>> Service.
> 
> 
> 
> .
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 
>