Jump to content
uberscientist

msp430-elf-gcc errors on builtin SR function

Recommended Posts

I'm getting this error:

main.c: In function 'Timer_A':
main.c:150:28: error: MSP430 builtin functions only work inside interrupt handlers
   __bic_SR_register_on_exit(CPUOFF);      // Clear CPUOFF bit from 0(SR)
                            ^
makefile:23: recipe for target 'main.o' failed

With this code:

// TimerA interrupt
__attribute__((__interrupt__(TIMERA0_VECTOR)))
Timer_A (void)
{
  iflag |= BIT0; // Set BIT0 flag
  __bic_SR_register_on_exit(CPUOFF);      // Clear CPUOFF bit from 0(SR)
}

For some reason msp430-elf-gcc thinks my ISR isn't an ISR :(

 

Any ideas? I emailed one of the red hat guys who submitted the GCC patch with the function that checks whether a function is an interrupt handler or not.

Share this post


Link to post
Share on other sites

I replied in your e2e thread, try taking off the double underscores flanking the "interrupt" keyword (but keep them around "attribute").

 

edit: nevermind, just saw your e2e reply, it didn't work... I am not sure why, that is odd though. I may experiment with this later if I find time.

 

Sent from my Galaxy Note II with Tapatalk 4

Share this post


Link to post
Share on other sites

Just for grins, try specifying a void return type on your function definition, and play around with the order of the return type and attribute declaration and the function declaration. It may be that the attribute is being associated with the implicit int return type, not with the function itself.

Share this post


Link to post
Share on other sites

Just for grins, try specifying a void return type on your function definition, and play around with the order of the return type and attribute declaration and the function declaration. It may be that the attribute is being associated with the implicit int return type, not with the function itself.

Tried a bunch of different ways, even searched github for "__attribute__((interrupt" to see how others were doing it to no avail.

 

I replied in your e2e thread, try taking off the double underscores flanking the "interrupt" keyword (but keep them around "attribute").

 

edit: nevermind, just saw your e2e reply, it didn't work... I am not sure why, that is odd though. I may experiment with this later if I find time.

 

Sent from my Galaxy Note II with Tapatalk 4

Thanks for your replies! Yeah, it didn't work, but I've left the underscores off for further tests though, I just copy-pasted this from that old post.

Share this post


Link to post
Share on other sites

Using this code:

#include <msp430.h>

volatile int iflag;

// TimerA interrupt
__attribute__((__interrupt__(TIMERA0_VECTOR)))
Timer_A (void)
{
  iflag |= BIT0; // Set BIT0 flag
  __bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
and my house-built gcc-4.9.1--based version of msp430-elf as:

/usr/local/msp430-elf-dev-20140602/bin/msp430-elf-gcc -I/usr/local/gcc-msp430-elf/msp430-elf/include -mmcu=msp430g2211 -c /tmp/q.c 
it works fine. For most other MCUs I get an error:

llc[11]$ /usr/local/msp430-elf-dev-20140602/bin/msp430-elf-gcc -I/usr/local/gcc-msp430-elf/msp430-elf/include -mmcu=msp430g2553 -c /tmp/q.c /tmp/q.c:8:1: warning: argument of 

Share this post


Link to post
Share on other sites

@pabigot:

Here's a gist of the makefile I'm using: https://gist.github.com/uberscientist/faba7f2050bf94d8176c

 

I'm using an MSP430G2755.  I've also tried both ways of spelling the interrupt constant, I wasn't sure which was better.

$ msp430-elf-gcc --version
msp430-elf-gcc (GCC) 4.8.0 20130315 (release (msp430-130423-272)) (Red Hat/devo) [trunk revision 196673]

I should check if there's a newer version... I haven't  :unsure: .

 

So it looks like you're getting the same error for most of the MCUs?

 

I just pushed my project as it stands (it's terribly messy, sorry) https://bitbucket.org/naked/msp-datalogger/src/b834e8e463d4af6470515bd298010fa6542ad24a/?at=fatfs

 

Thank you very much for looking into this with me  :smile:

Share this post


Link to post
Share on other sites
$ grep VECTOR  msp430g2755.h
#define TIMER0_B1_VECTOR    TIMERB1_VECTOR /* Int. Vector: Timer B CC1-2, TB */
#define TIMER0_B0_VECTOR    TIMERB0_VECTOR /* Int. Vector: Timer B CC0 */
#define TIMER1_A1_VECTOR        ( 1)                     /* 0xFFE0 Timer1_A CC1-4, TA1 */
#define TIMER1_A0_VECTOR        ( 2)                     /* 0xFFE2 Timer1_A CC0 */
#define PORT1_VECTOR            ( 3)                     /* 0xFFE4 Port 1 */
#define PORT2_VECTOR            ( 4)                     /* 0xFFE6 Port 2 */
#define TRAPINT_VECTOR          ( 5)                     /* 0xFFE8 TRAPINT */
#define ADC10_VECTOR            ( 6)                     /* 0xFFEA ADC10 */
#define USCIAB0TX_VECTOR        ( 7)                     /* 0xFFEC USCI A0/B0 Transmit */
#define USCIAB0RX_VECTOR        ( 8)                     /* 0xFFEE USCI A0/B0 Receive */
#define TIMER0_A1_VECTOR        ( 9)                     /* 0xFFF0 Timer0_A CC1, TA0 */
#define TIMER0_A0_VECTOR        (10)                     /* 0xFFF2 Timer0_A CC0 */
#define WDT_VECTOR              (11)                     /* 0xFFF4 Watchdog Timer */
#define COMPARATORA_VECTOR      (12)                     /* 0xFFF6 Comparator A */
#define TIMERB1_VECTOR          (13)                     /* 0xFFF8 Timer B CC1-6, TB */
#define TIMERB0_VECTOR          (14)                     /* 0xFFFA Timer B CC0 */
#define NMI_VECTOR              (15)                     /* 0xFFFC Non-maskable */
#define RESET_VECTOR            ("reset")                /* 0xFFFE Reset [Highest Priority] */
 

Seems like you are using the wrong vector name for that chip.

 

-rick

Share this post


Link to post
Share on other sites

@pabigot:

Here's a gist of the makefile I'm using: https://gist.github.com/uberscientist/faba7f2050bf94d8176c

 

I'm using an MSP430G2755.  I've also tried both ways of spelling the interrupt constant, I wasn't sure which was better.

$ msp430-elf-gcc --version
msp430-elf-gcc (GCC) 4.8.0 20130315 (release (msp430-130423-272)) (Red Hat/devo) [trunk revision 196673]
I should check if there's a newer version... I haven't  :unsure: .

 

The last TI version I've seen is 371, but I work from the GCC trunk version (backported to the 4.9 branch), which probably doesn't exactly match what's in TI's version but is at least convenient.

 

http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/latest/index_FDS.html suggests 371 is TI's version.

 

So it looks like you're getting the same error for most of the MCUs?

I get the diagnostic in my post, specifically with the G2755. I have never gotten the diagnostic you've shown.

 

Peter

Share this post


Link to post
Share on other sites

Heh---looking back, obviously I do get the diagnostic you've shown since it's present in what I quoted. It just shows up after the first one (the warning), which is where I stopped reading because it was obviously the problem.

 

Understandable if 272 doesn't warn about the unrecognized value.

Share this post


Link to post
Share on other sites

You might need to add the -Wall flag to your linker, in my gcc-elf it throws a warning when you are using an undefined ISR vector.

It works now, Rick pointed out my silly mistake, I had got a new chip and didn't know TI had changed the VECTOR names in the header file >.<;

 

I tried to edit the title of the OP with [solved] like the Arch forums, but I couldn't :(

 

Thanks though greeeg :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...