RE: [AVR-Chat] convert port to binary number
2004-09-28 by Stuart Whelan
Actually, I did what the others before me did and failed to actually read your message. Sorry. :)
This the kind of thing you want? (not tested)
unsigned int Result;
// Grab the first 6 pins states on port b and put it into result.
Result = PINB & 0x3f;
// Move the current value of result left 6 bits.
Result <<= 6;
// Grab the first 6 pins states on port a and put it into the first 6 bits of result.
Result += (PINA & 0x3f);
printf("Port state is %d\n\r", Result);
Kind Regards,
Stuart Whelan
Technical Director
Pacific Simulators LTD
DDI: +64 3 3778866
Mobile: +64 27 2828074
Recursion: See Recursion.
> -----Original Message-----
> From: Stuart Whelan [mailto:stuart.whelan@pacific-simulators.co.nz]
> Sent: Tuesday, 28 September 2004 4:32 p.m.
> To: AVR-Chat@yahoogroups.com
> Subject: RE: [AVR-Chat] convert port to binary number
>
> I am guessing that by a binary number you mean an output in
> binary format, like '01010101'?
>
> Kind Regards,
> Stuart Whelan
> Technical Director
> Pacific Simulators LTD
>
> DDI: +64 3 3778866
> Mobile: +64 27 2828074
>
> Recursion: See Recursion.
>
> > -----Original Message-----
> > From: jim_rinaudo [mailto:jravionics@webworkz.com]
> > Sent: Tuesday, 28 September 2004 2:05 p.m.
> > To: AVR-Chat@yahoogroups.com
> > Subject: [AVR-Chat] convert port to binary number
> >
> > OK, I surrender. I tried all the searches I can think of
> and I need
> > to find the command that takes all the input states of a port and
> > makes it a single binary number. I looked in my codevision help
> > section and no help there either.
> >
> > The input is 12 bits arranged in groups of three so I plan
> on using 6
> > inputs in port a and 6 in port b and convert each six into
> one big 12
> > bit number. then I use the 12 bit number to compare to a value in
> > an array and output an equivalent decimal.
> >
> > Can anyone give me a clue.
> >
> > thanks
> >
> > Jim
> >
> >
> >
> > ------------------------ Yahoo! Groups Sponsor
> > --------------------~-->
> > $9.95 domain names from Yahoo!. Register anything.
> > http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/dN_tlB/TM
> > --------------------------------------------------------------
> > ------~->
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> > --
> > Incoming mail is certified Virus Free.
> > Checked by AVG Anti-Virus (http://www.grisoft.com).
> > Version: 7.0.271 / Virus Database: 264.9.7 - Release Date:
> 27/09/2004
> >
> >
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG Anti-Virus (http://www.grisoft.com).
> Version: 7.0.271 / Virus Database: 264.9.7 - Release Date: 27/09/2004
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> $9.95 domain names from Yahoo!. Register anything.
> http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/dN_tlB/TM
> --------------------------------------------------------------
> ------~->
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
> --
> Incoming mail is certified Virus Free.
> Checked by AVG Anti-Virus (http://www.grisoft.com).
> Version: 7.0.271 / Virus Database: 264.9.7 - Release Date: 27/09/2004
>
>
--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.271 / Virus Database: 264.9.7 - Release Date: 27/09/2004