This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
i am trying to blink led using timer ..but i keep getting the errors
--expected a field name
-TACTL_bit is undefined
my code is as follows..please help anyone ??
/*
* main.c
*/
#include<msp430g2553.h>
#define LED1 BIT0
#define LED2 BIT6
void main(void)
{
WDTCTL = WDTPW | WDTHOLD;
P2DIR = LED1 | LED2 ;
P2OUT = ~LED1 | ~LED2 ;
TACTL = MC_2 | ID_3 | TASSEL_2 |TACLR | TAIE ;
for(;;)
{
while(TACTL_bit.TAIFG == 0)
{
}
TACTL_bit.TAIFG=0;
P2OUT ^= LED1 | LED2 ;
}
}
The compiler is telling you that it does not know what is TACTL_bit.TAIFG, You have two options to fix this problem:
1. Do not use TACTL_bi.TAIFG
2. Define what you mean by TACTL_bit.TAIFG
I think by TACTL_bit.TAIFG you are trying to check if there are any timer interrupt but this syntax is not defined in the header file.
You can replace it with TAIFG only, but it is better to use an interrupt service routine which you can find from the example codes provided from TI.
Regards
Gunay
i am new to c programming till now i have just been working with assembly i dont know much about c..can u help me on what is the syntax for accessing individual of a register in ccs ??
which header contains details about accessing individual bits of a register ??
You probably do not have such a header file. And that is why you got that error msg to begin with.
Usually, TACTL is defined and TAIFG is defined too. Thus TACTL & TAIFG can be used instead of the undefined TACTL_bit.TAIFG
WITH UR HELP I WAS ABLE TO ELIMINATE THE ERROR BUT STILL NOT GETTING THE OUPUT ..
THE CHANGED CODE IS..
/*
* main.c
*/
#include<msp430g2553.h>
#define LED1 BIT0
#define LED2 BIT6
void main(void)
{
WDTCTL = WDTPW | WDTHOLD;
P1DIR = LED1 |LED2;
P1OUT = LED1 |LED2;
TACTL = MC_2 | ID_3 | TASSEL_2 |TACLR | TAIE ;
for(;;)
{
while(TACTL&TAIFG == 0)
{
}
TACTL^=TAIFG;
P1OUT ^=LED1 |LED2;
}
}
To the c-compiler, (TACTL&TAIFG == 0) means (TACTL&(TAIFG == 0)). That is not what you want. You need to say ((TACTL & TAIFG) == 0)
You are welcome.
BTW, you set the TAIE bit in TACTL. This is unnecessary and should be avoided when you do not have an ISR to handle it. But fortunately, you did not set GIE, so TAIE did not hurt you.
Also, you use TACTL ^= TAIFG; to reset that flag. It works only when it was set (as in you case). It is cleaner to use TACTL &= ~TAIFG; to reset the flag.
will taken in these considerations and will make changes to the program code .
**Attention** This is a public forum