Sign in

username:

password:



Not a member?

Search msp430



Search tips

Subscribe to msp430



Ads

Discussion Groups

Discussion Groups | MSP430 | Port manipulation

The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.

Port manipulation - magzky02 - Aug 4 2:15:10 2008

Good day to everyone. I just want to ask how you manipulate mps430
ports. When i toggle high a port, i use 'or' 1 when low, i use 'and' 0
(ex, P2OUT |= 0x02, P2OUT &= ~0x02). Now, want to define a single
port so that i can manipulate it independently. so if i define a port
to SPI_CS0, i can easily write SPI_CS0 = 0, or SPI_CS0 = 1. Any help?
I am using IAR. (when i use AVR, my compiler supports manipulation
like PORTA.1 = 1, or PORTA.1 = 0. When i used PIC, i also use RA1 = 1,
RA1 = 0. what about MSP430 with IAR?)

regards,
mago

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )


Re: Port manipulation - bb_stefan - Aug 4 3:06:27 2008

I often use defines:

#define SET_PORT_X (P2OUT |= 0x02) // P2.1 high
#define RESET_PORT_X (P2OUT &= ~0x02) // P2.1 low

For me it has the advantage, that you don't have to remember the
port-pin number, instead a meaningful name is used. Another advantage
is (in my opinion), if you have a signal that is low active you can
define the other way round:
#define SET_PORT_X (P2OUT &= ~0x02) // P2.1 low-active
#define RESET_PORT_X (P2OUT |= 0x02) // P2.1 high-inactive

--- In m...@yahoogroups.com, "magzky02" wrote:
>
> Good day to everyone. I just want to ask how you manipulate mps430
> ports. When i toggle high a port, i use 'or' 1 when low, i use 'and' 0
> (ex, P2OUT |= 0x02, P2OUT &= ~0x02). Now, want to define a single
> port so that i can manipulate it independently. so if i define a port
> to SPI_CS0, i can easily write SPI_CS0 = 0, or SPI_CS0 = 1. Any help?
> I am using IAR. (when i use AVR, my compiler supports manipulation
> like PORTA.1 = 1, or PORTA.1 = 0. When i used PIC, i also use RA1 = 1,
> RA1 = 0. what about MSP430 with IAR?)
>
> regards,
> mago
>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Port manipulation - old_cow_yellow - Aug 4 3:52:57 2008

Some prefers to use:

P2OUT_bit.P2OUT_1 = 1; // instead of: P2OUT |= 0x02;
P2OUT_bit.P2OUT_1 = 0; // instead of: P2OUT &= ~0x02;

It is all a matter of definition of symbols. Compiles into the same
assembly (or machine) code.

I prefer to use:

bis.b #BIT1,&P2OUT;
bic.b #BIT1,&P2OUT;

Why go through the middleman?

--- In m...@yahoogroups.com, "bb_stefan" wrote:
>
> I often use defines:
>
> #define SET_PORT_X (P2OUT |= 0x02) // P2.1 high
> #define RESET_PORT_X (P2OUT &= ~0x02) // P2.1 low
>
> For me it has the advantage, that you don't have to remember the
> port-pin number, instead a meaningful name is used. Another advantage
> is (in my opinion), if you have a signal that is low active you can
> define the other way round:
> #define SET_PORT_X (P2OUT &= ~0x02) // P2.1 low-active
> #define RESET_PORT_X (P2OUT |= 0x02) // P2.1 high-inactive
> --- In m...@yahoogroups.com, "magzky02" wrote:
> >
> > Good day to everyone. I just want to ask how you manipulate mps430
> > ports. When i toggle high a port, i use 'or' 1 when low, i use
'and' 0
> > (ex, P2OUT |= 0x02, P2OUT &= ~0x02). Now, want to define a single
> > port so that i can manipulate it independently. so if i define a port
> > to SPI_CS0, i can easily write SPI_CS0 = 0, or SPI_CS0 = 1. Any help?
> > I am using IAR. (when i use AVR, my compiler supports manipulation
> > like PORTA.1 = 1, or PORTA.1 = 0. When i used PIC, i also use RA1
= 1,
> > RA1 = 0. what about MSP430 with IAR?)
> >
> > regards,
> > mago
>
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: Port manipulation - mago Umandam - Aug 4 4:13:14 2008

Thanks pips. I got ideas from you... It is a good thing we explore things o=
urselves. But sometimes, its better to get ideas from other experienced peo=
ple. And we realize there are much simpler ways to do the things that initi=
ally=A0seem quite confusing.
=A0
cheers,
mago

--- On Mon, 8/4/08, old_cow_yellow wrote:

From: old_cow_yellow
Subject: [msp430] Re: Port manipulation
To: m...@yahoogroups.com
Date: Monday, August 4, 2008, 3:52 PM

Some prefers to use:

P2OUT_bit.P2OUT_ 1 =3D 1; // instead of: P2OUT |=3D 0x02;
P2OUT_bit.P2OUT_ 1 =3D 0; // instead of: P2OUT &=3D ~0x02;

It is all a matter of definition of symbols. Compiles into the same
assembly (or machine) code.

I prefer to use:

bis.b #BIT1,&P2OUT;
bic.b #BIT1,&P2OUT;

Why go through the middleman?

--- In msp430@yahoogroups. com, "bb_stefan" wrote:
>
> I often use defines:
>=20
> #define SET_PORT_X (P2OUT |=3D 0x02) // P2.1 high
> #define RESET_PORT_X (P2OUT &=3D ~0x02) // P2.1 low
>=20
> For me it has the advantage, that you don't have to remember the
> port-pin number, instead a meaningful name is used. Another advantage
> is (in my opinion), if you have a signal that is low active you can
> define the other way round:
> #define SET_PORT_X (P2OUT &=3D ~0x02) // P2.1 low-active
> #define RESET_PORT_X (P2OUT |=3D 0x02) // P2.1 high-inactive
>=20
>=20
>=20
>=20
> --- In msp430@yahoogroups. com, "magzky02" wrote:
> >
> > Good day to everyone. I just want to ask how you manipulate mps430=20
> > ports. When i toggle high a port, i use 'or' 1 when low, i use
'and' 0=20
> > (ex, P2OUT |=3D 0x02, P2OUT &=3D ~0x02). Now, want to define a single=20
> > port so that i can manipulate it independently. so if i define a port=20
> > to SPI_CS0, i can easily write SPI_CS0 =3D 0, or SPI_CS0 =3D 1. Any hel=
p?=20
> > I am using IAR. (when i use AVR, my compiler supports manipulation=20
> > like PORTA.1 =3D 1, or PORTA.1 =3D 0. When i used PIC, i also use RA1
=3D 1,=20
> > RA1 =3D 0. what about MSP430 with IAR?)
> >=20
> > regards,
> > mago
>
=20

=20=20=20=20=20=20

[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )