EmbeddedRelated.com
Forums

problems with program

Started by msp430 nascimento July 8, 2007
Hi I started to programmer MSP430f2012 this saturday, and I found problems to compile the following program:
#include "msp430x20x2.h"
// delay_ms(void) ;
#define LED P1OUT_BIT.P1OUT_0
#define botao P1IN_bit.P1IN_1
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
while(1)
{
IF (botao) LED=0; else LED=1;
}
}
I would like to set Led when I press oush button.Someone can help me?

I use eZ430F2012.
Thanks and Have a good weekend

Carlos Henrique Nascimento Martins
Phone: (55)(32)(88138750)
Hardware development (Analog, digital, Microprocessers (DSP), Microcontrollers device (PIC and MSP))

____________________________________________________________________________________
Novo Yahoo! Cad - Experimente uma nova busca.
http://yahoo.com.br/oqueeuganhocomisso

Beginning Microcontrollers with the MSP430

(1) Do not use the header file "msp430x20x2.h"
Try "io430x20x2.h" instead.
Or simply "io430.h" and specify F2002/F2012 in the project options.

(2) Correct the case of "BIT", use "P1OUT_bit.P1OUT_0"

(3) Correct the spelling of "P1IN_1", use "P1IN_bit.P0IN_1"
(-; Do not ask why ;-)

--- In m..., msp430 nascimento
wrote:
>
> Hi I started to programmer MSP430f2012 this saturday, and I found
problems to compile the following program:
> #include "msp430x20x2.h"
> // delay_ms(void) ;
> #define LED P1OUT_BIT.P1OUT_0
> #define botao P1IN_bit.P1IN_1
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
> P1DIR |= 0x01; // Set P1.0 to output direction
> while(1)
> {
> IF (botao) LED=0; else LED=1;
> }
> }
> I would like to set Led when I press oush button.Someone can help
me?
>
> I use eZ430F2012.
> Thanks and Have a good weekend
>
> Carlos Henrique Nascimento Martins
> Phone: (55)(32)(88138750)
> Hardware development (Analog, digital, Microprocessers (DSP),
Microcontrollers device (PIC and MSP))
>
>
>
______________________________________________________________________
______________
> Novo Yahoo! Cad? - Experimente uma nova busca.
> http://yahoo.com.br/oqueeuganhocomisso
>
>
>
#include "msp430x20x2.h"
// delay_ms(void) ;
#define LED P1OUT_bit.P1OUT_ 0
#define botao P1IN_bit.P0IN_ 1
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
//P1DIR_bit.P1DIR_0=1;
//P1DIR_bit.P1DIR_1=0;
while(1)
//for (;;)
{
IF (botao);
LED=0; else
LED=1;
}
}

I tried to compile the program with your suggests, but io430.h and io430x20x2 dind`t work... I use IAR, and now the mistake after compile is
Error[Pe020]: identifier "P1IN_bit" is undefined C:\Program Files\IAR Systems\Embedded Workbench 4.0\430\FET_examples\msp430x2xx\C-source\msp430x2xx_fet_1.c 34
Error[Pe018]: expected a ")" C:\Program Files\IAR Systems\Embedded Workbench 4.0\430\FET_examples\msp430x2xx\C-source\msp430x2xx_fet_1.c 34
Error[Pe020]: identifier "P1OUT_bit" is undefined C:\Program Files\IAR Systems\Embedded Workbench 4.0\430\FET_examples\msp430x2xx\C-source\msp430x2xx_fet_1.c 35
Error[Pe134]: expected a field name C:\Program Files\IAR Systems\Embedded Workbench 4.0\430\FET_examples\msp430x2xx\C-source\msp430x2xx_fet_1.c 35
Error[Pe127]: expected a statement C:\Program Files\IAR Systems\Embedded Workbench 4.0\430\FET_examples\msp430x2xx\C-source\msp430x2xx_fet_1.c 35

I didn`t understand what happened. Can you help me? Thanks

----- Mensagem original ----
De: old_cow_yellow
Para: m...
Enviadas: Domingo, 8 de Julho de 2007 12:53:36
Assunto: [msp430] Re: problems with program

(1) Do not use the header file "msp430x20x2. h"

Try "io430x20x2. h" instead.

Or simply "io430.h" and specify F2002/F2012 in the project options.

(2) Correct the case of "BIT", use "P1OUT_bit.P1OUT_ 0"

(3) Correct the spelling of "P1IN_1", use "P1IN_bit.P0IN_ 1"

(-; Do not ask why ;-)

--- In msp430@yahoogroups. com, msp430 nascimento

wrote:

>

> Hi I started to programmer MSP430f2012 this saturday, and I found

problems to compile the following program:

>

>

> #include "msp430x20x2. h"

> // delay_ms(void) ;

> #define LED P1OUT_BIT.P1OUT_ 0

> #define botao P1IN_bit.P1IN_ 1

> void main(void)

> {

> WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

> P1DIR |= 0x01; // Set P1.0 to output direction

> while(1)

> {

> IF (botao) LED=0; else LED=1;

> }

> }

>

>

> I would like to set Led when I press oush button.Someone can help

me?

>

> I use eZ430F2012.

> Thanks and Have a good weekend

>

>

>

> Carlos Henrique Nascimento Martins

> Phone: (55)(32)(88138750)

> Hardware development (Analog, digital, Microprocessers (DSP),

Microcontrollers device (PIC and MSP))

>

>

>

>

>

>

>

____________ _________ _________ _________ _________ _________ _

____________ __

> Novo Yahoo! Cad? - Experimente uma nova busca.

> http://yahoo. com.br/oqueeugan hocomisso

>

>

>



____________________________________________________________________________________
Novo Yahoo! Cad - Experimente uma nova busca.
http://yahoo.com.br/oqueeuganhocomisso
You and I are probably using different versions of IAR. What works
for me does not work for you. For all I know, it might not work for
me either three months form now.

What happens is, P1IN_bit and P1OUT_bit are defined in "io430x20x2"
but not in "msp430x20x2". Thus you cannot use them.

Here is an alternative (not sure which one is ON, which one is OFF):
...
#define LED_ON P1OUT &= ~0x01
#define LED_OFF P1OUT |= 0x01
#define botao P1IN & 0x02
...
if (botao) LED_ON;
else LED_OFF;
...

--- In m..., msp430 nascimento
wrote:
>
> #include "msp430x20x2.h"
> // delay_ms(void) ;
> #define LED P1OUT_bit.P1OUT_ 0
> #define botao P1IN_bit.P0IN_ 1
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
> P1DIR |= 0x01; // Set P1.0 to output direction
> //P1DIR_bit.P1DIR_0=1;
> //P1DIR_bit.P1DIR_1=0;
> while(1)
> //for (;;)
> {
> IF (botao);
> LED=0; else
> LED=1;
> }
> }
>
> I tried to compile the program with your suggests, but io430.h and
io430x20x2 dind`t work... I use IAR, and now the mistake after
compile is
> Error[Pe020]: identifier "P1IN_bit" is undefined C:\Program
Files\IAR Systems\Embedded Workbench 4.0\430
\FET_examples\msp430x2xx\C-source\msp430x2xx_fet_1.c 34
> Error[Pe018]: expected a ")" C:\Program Files\IAR Systems\Embedded
Workbench 4.0\430\FET_examples\msp430x2xx\C-source\msp430x2xx_fet_1.c
34
> Error[Pe020]: identifier "P1OUT_bit" is undefined C:\Program
Files\IAR Systems\Embedded Workbench 4.0\430
\FET_examples\msp430x2xx\C-source\msp430x2xx_fet_1.c 35
> Error[Pe134]: expected a field name C:\Program Files\IAR
Systems\Embedded Workbench 4.0\430\FET_examples\msp430x2xx\C-
source\msp430x2xx_fet_1.c 35
> Error[Pe127]: expected a statement C:\Program Files\IAR
Systems\Embedded Workbench 4.0\430\FET_examples\msp430x2xx\C-
source\msp430x2xx_fet_1.c 35
>
> I didn`t understand what happened. Can you help me? Thanks
>
old_cow_yellow wrote:
> You and I are probably using different versions of IAR. What works
> for me does not work for you. For all I know, it might not work for
> me either three months form now.
>
> What happens is, P1IN_bit and P1OUT_bit are defined in "io430x20x2"
> but not in "msp430x20x2". Thus you cannot use them.
>
> Here is an alternative (not sure which one is ON, which one is OFF):
> ...
> #define LED_ON P1OUT &= ~0x01
> #define LED_OFF P1OUT |= 0x01
> #define botao P1IN & 0x02
> ...
> if (botao) LED_ON;
> else LED_OFF;
> ...
>
> --- In m..., msp430 nascimento
> wrote:
>> #include "msp430x20x2.h"

#include "io430x20x2.h"

>> // delay_ms(void) ;
>> #define LED P1OUT_bit.P1OUT_ 0

#define LED P1OUT_bit.P1OUT_0
^ no space

>> #define botao P1IN_bit.P0IN_ 1

#define botao P1IN_bit.P0IN_1
^ no space

>> void main(void)
>> {
>> WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
>> P1DIR |= 0x01; // Set P1.0 to output direction
>> //P1DIR_bit.P1DIR_0=1;
>> //P1DIR_bit.P1DIR_1=0;
>> while(1)
>> //for (;;)
>> {
>> IF (botao);
>> LED=0; else
>> LED=1;
>> }
>> }
>>
>> I tried to compile the program with your suggests, but io430.h and
> io430x20x2 dind`t work... I use IAR, and now the mistake after
> compile is
>> Error[Pe020]: identifier "P1IN_bit" is undefined C:\Program
> Files\IAR Systems\Embedded Workbench 4.0\430
> \FET_examples\msp430x2xx\C-source\msp430x2xx_fet_1.c 34
>> Error[Pe018]: expected a ")" C:\Program Files\IAR Systems\Embedded
> Workbench 4.0\430\FET_examples\msp430x2xx\C-source\msp430x2xx_fet_1.c
> 34
>> Error[Pe020]: identifier "P1OUT_bit" is undefined C:\Program
> Files\IAR Systems\Embedded Workbench 4.0\430
> \FET_examples\msp430x2xx\C-source\msp430x2xx_fet_1.c 35
>> Error[Pe134]: expected a field name C:\Program Files\IAR
> Systems\Embedded Workbench 4.0\430\FET_examples\msp430x2xx\C-
> source\msp430x2xx_fet_1.c 35
>> Error[Pe127]: expected a statement C:\Program Files\IAR
> Systems\Embedded Workbench 4.0\430\FET_examples\msp430x2xx\C-
> source\msp430x2xx_fet_1.c 35
>>
>> I didn`t understand what happened. Can you help me? Thanks
>