LPC2200 Application Note on SPI (AN10369)
2006-05-11 by wickedmonster2002
Yahoo Groups archive
Index last updated: 2026-04-28 23:31 UTC
Thread
2006-05-11 by wickedmonster2002
I am confused. What does #define SPIF (1<<7) mean? Everything else I understand.
2006-05-11 by Marko Pavlin (home)
wickedmonster2002 wrote: > I am confused. What does #define SPIF (1<<7) mean? Everything else I > understand. > 1<<7 means 1 binary shifted left 7 places (bits). The result is 0x80 or 8'th bit set to 1. It is equal to: #define SPIF 0x80
2006-05-11 by Andrew Berney
It creates a pre-processor definition (#define) such that where ever SPIF is used in the code it compiles it as though it was: (1<<7). Or if you mean what does 1<<7 do? Then the << is a bitwise operator in C that shifts the value (in this case 0x01) 7 places to the left becomes 0x80. Get yourself a decent book on C, there's plenty out there... Andy
-----Original Message----- From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On Behalf Of wickedmonster2002 Sent: 11 May 2006 15:42 To: lpc2000@yahoogroups.com Subject: [lpc2000] LPC2200 Application Note on SPI (AN10369) I am confused. What does #define SPIF (1<<7) mean? Everything else I understand. Yahoo! Groups Links
2006-05-11 by Tom Walsh
wickedmonster2002 wrote: >I am confused. What does #define SPIF (1<<7) mean? Everything else I > > What is 2 raised to the 7th power? This is a C statement to shift a value of "1" left by "7" bit positions. Simply write a binary "1" followed by 7 "0"s. Then convert the binary number into your favorite number base: octal, hex or decimal. Next, use your calculator to raise 2 to the 7th power. See the relationships? TomW -- Tom Walsh - WN3L - Embedded Systems Consultant http://openhardware.net, http://cyberiansoftware.com "Windows? No thanks, I have work to do..." ----------------------------------------------------
2006-05-11 by brendanmurphy37
--- In lpc2000@yahoogroups.com, "wickedmonster2002" <karim@...> wrote:
>
> I am confused. What does #define SPIF (1<<7) mean? Everything else I
> understand.
>
As others have pointed out discovering **what** it means is very
simple: it's just standard 'C'.
What's less obvious is **why** this construct is used. I believe the
following is the main reason:
In many peripheral register descriptions, you will see the function of
individual bits described. This is the case for "SPIF", which is bit 7
in SPSR. Rather than work out by hand (and perhaps getting it wrong),
the simplest thing is to get the pre-processor to do it for you. In the
general case:
#define BIT_NAME (1 << bit_position)
That way it's easy to cross check the definition in the code against
the documentation.
You can then use it in code to select the bit of interest as follows:
if (S0SPSR & SPIF)
{
do_something();
}
Brendan2006-05-11 by wickedmonster2002
Thanks guys for all the variable answers. I am pro in Assembly programming. I m just getting into C. I was used to C++ before, but that was before I got into Embedded systems. --- In lpc2000@yahoogroups.com, "wickedmonster2002" <karim@...> wrote:
> > I am confused. What does #define SPIF (1<<7) mean? Everything else I > understand. >
2006-05-12 by jk jlkj
Hey Karim are u into weighing scales by any chance.
wickedmonster2002 <karim@...> wrote: Thanks guys for all the variable answers. I am pro in Assembly
programming. I m just getting into C. I was used to C++ before, but
that was before I got into Embedded systems.
--- In lpc2000@yahoogroups.com, "wickedmonster2002" <karim@...> wrote:
>
> I am confused. What does #define SPIF (1<<7) mean? Everything else I
> understand.
>
SPONSORED LINKS
Microcontrollers Microprocessor Intel microprocessors
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "lpc2000" on the web.
To unsubscribe from this group, send an email to:
lpc2000-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Yahoo! India Answers: Share what you know. Learn something new. Click here
Send instant messages to your online friends - NOW
[Non-text portions of this message have been removed]2006-05-12 by wickedmonster2002
Yes I am...I just got into it a month and half ago. Excellent Educated Guess by the way. --- In lpc2000@yahoogroups.com, jk jlkj <njad2002@...> wrote: > > Hey Karim are u into weighing scales by any chance. > > wickedmonster2002 <karim@...> wrote: Thanks guys for all the variable answers. I am pro in Assembly > programming. I m just getting into C. I was used to C++ before, but > that was before I got into Embedded systems. > > > --- In lpc2000@yahoogroups.com, "wickedmonster2002" <karim@> wrote: > > > > I am confused. What does #define SPIF (1<<7) mean? Everything else I > > understand. > > > > > > > > > SPONSORED LINKS > Microcontrollers Microprocessor Intel microprocessors > > --------------------------------- > YAHOO! GROUPS LINKS > > > Visit your group "lpc2000" on the web. > > To unsubscribe from this group, send an email to: > lpc2000-unsubscribe@yahoogroups.com > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. > > > --------------------------------- > > > > > > --------------------------------- > Yahoo! India Answers: Share what you know. Learn something new. Click here
> Send instant messages to your online friends - NOW > > [Non-text portions of this message have been removed] >
2006-05-13 by jk jlkj
where r u working from, ru in the US.
wickedmonster2002 <karim@...> wrote: Yes I am...I just got into it a month and half ago. Excellent Educated
Guess by the way.
--- In lpc2000@yahoogroups.com, jk jlkj <njad2002@...> wrote:
>
> Hey Karim are u into weighing scales by any chance.
>
> wickedmonster2002 <karim@...> wrote: Thanks guys for all the
variable answers. I am pro in Assembly
> programming. I m just getting into C. I was used to C++ before, but
> that was before I got into Embedded systems.
>
>
> --- In lpc2000@yahoogroups.com, "wickedmonster2002" <karim@> wrote:
> >
> > I am confused. What does #define SPIF (1<<7) mean? Everything else I
> > understand.
> >
>
>
>
>
>
>
> SPONSORED LINKS
> Microcontrollers Microprocessor Intel microprocessors
>
> ---------------------------------
> YAHOO! GROUPS LINKS
>
>
> Visit your group "lpc2000" on the web.
>
> To unsubscribe from this group, send an email to:
> lpc2000-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.
>
>
> ---------------------------------
>
>
>
>
>
> ---------------------------------
> Yahoo! India Answers: Share what you know. Learn something new.
Click here
> Send instant messages to your online friends - NOW
>
> [Non-text portions of this message have been removed]
>
SPONSORED LINKS
Microcontrollers Microprocessor Intel microprocessors
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "lpc2000" on the web.
To unsubscribe from this group, send an email to:
lpc2000-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
What makes Sachin India's highest paid sports celebrity?, Share your knowledge on Yahoo! India Answers
Send instant messages to your online friends - NOW
[Non-text portions of this message have been removed]