SOLVED: migration from AS4 to AS6; build failure on poisoned

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Migrated a project that compiled successfully under AS4 to AS6. I get the following error:
"Error 1 attempt to use poisoned SIG_INTERRUPT1"

I have researched the board for similar errors and have found they are related to a)improper MCU selection or b)not including . A stripped down example of the code is below. I have verified that the make file is using atmega8 as the mcu. Any suggestions?

/*
 * garage_light.c
 *
 * Created: 1/8/2013 7:11:21 PM
 *  Author: Mark
 */ 


#include 
#include 

int triac_delay = 8200;

SIGNAL (SIG_INTERRUPT1)
{
	cli();							//turn off interrupts
	OCR1A = triac_delay;			//set output compare A to triac delay
	OCR1B = triac_delay + 8333;		//set output compare B to triac delay + 8.3 ms
	TCNT1 = 0x00;					//start timer 1 at zero
	sei();
}

int main(void)
{
    while(1)
    {
        //TODO:: Please write your application code 
    }
}
Last Edited: Fri. Jan 11, 2013 - 07:39 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your vesion must have been quite old.
Please refer to http://www.nongnu.org/avr-libc/u... for the changed interrupt names.

SIGNAL (SIG_INTERRUPT1) has been replaced by ISR(INT1_vect)

Alex

Added:
There is also no need to use cli() at the start of the interrupt and sei() at the end , this is already the default behaviour and can be changed if there is a need for that using the ISR attributes described in the interrupt.h link of the previous post.

"For every effect there is a root cause. Find and address the root cause rather than try to fix the effect, as there is no end to the latter."
Author Unknown

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

if you want to reuse all your old code without change, you are able to change the compiler to the version (most likely winAvr i'm guessing) you used in AS4. This allows you to have all your old code compile in the new AS6 IDE.

To switch your AS6 toolchain:
1) Select the "Tools" -> "Options" from the File Menu.
2) Select "Toolchain" -> "Flavour Configuration"
3) Select the Toolchain from the drop down menu you with to use, such as "Atmel AVR 8-bit".
4) Click "Add Flavour"
5) Fill in flavour info, for example:
Name: WinAvr-20090313
Toolchain Path: ..\WinAVR\WinAVR-20090313\bin
Make Path: ..\WinAVR\WinAVR-20090313\utils\bin
6) You can set as default if you wish, or just click ok.
7) Go to the project properties (Right click on your project in the Solution exploror).
8) The advanced tab lets you select your toolchain flavour for a given project.

Here is a link of how it was changed in AS5 (Slightly different than AS6 but the same result):
http://avrstudio5.wordpress.com/2011/03/02/how-to-change-the-gcc-toolchain-used/

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the suggestions. I will try those this evening.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alexan_e wrote:
There is also no need to use [...] sei() at the end [of the interrupt], this is already the default behaviour
Not quote, it's completely different.

RETI performs setting of the I flag implicitly, but an explicit SEI is performed before the ISR epilogue whcih is a complete different story. For example, it allows interrupt nesting.

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes I'm aware of that but I don't think sei() was placed at the end of the ISR handler to enable recursive interrupts, seems to me like a side-effect of trying to re-enable interrupts.
I may be wrong of course but the cli() at the first line and the sei() at the last one make me think that recursiveness was not the original intention.
In any case thank you for pointing this out.

Alex

"For every effect there is a root cause. Find and address the root cause rather than try to fix the effect, as there is no end to the latter."
Author Unknown

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My frustration with this problem is driven by the fact that SIG_INTERRUPT1 is #define in iom8.h, which is the device specific header file for the atmega8.

/* External Interrupt Request 1 */
#define INT1_vect_num		2
#define INT1_vect			_VECTOR(2)
#define SIG_INTERRUPT1			_VECTOR(2)

io8m.h in turn is referenced by io.h. So, I have io.h in play, and the make file build statement has the -mmcu=atmega8 flag set.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If it is defined as you show then you can use

ISR(SIG_INTERRUPT1)

but I'm not sure how you can make the SIGNAL() version work.

Alex

"For every effect there is a root cause. Find and address the root cause rather than try to fix the effect, as there is no end to the latter."
Author Unknown

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't get it. The in AS6 still has:

#ifdef __cplusplus
#  define SIGNAL(vector)					\
    extern "C" void vector(void) __attribute__ ((signal, __INTR_ATTRS));	\
    void vector (void)
#else
#  define SIGNAL(vector)					\
    void vector (void) __attribute__ ((signal, __INTR_ATTRS));		\
    void vector (void)
#endif

While it's a bad idea and should be changed as soon as possible the fact is that SIGNAL(SIG_INTERUPT1) should still work for mega8.

EDIT: Oh I see it iom8.h contains this:

#if !defined(__AVR_LIBC_DEPRECATED_ENABLE__)

#pragma GCC system_header

#pragma GCC poison SIG_INTERRUPT0
#pragma GCC poison SIG_INTERRUPT1
#pragma GCC poison SIG_OUTPUT_COMPARE2
#pragma GCC poison SIG_OVERFLOW2
#pragma GCC poison SIG_INPUT_CAPTURE1
#pragma GCC poison SIG_OUTPUT_COMPARE1A
#pragma GCC poison SIG_OUTPUT_COMPARE1B
#pragma GCC poison SIG_OVERFLOW1
#pragma GCC poison SIG_OVERFLOW0
#pragma GCC poison SIG_SPI
#pragma GCC poison SIG_UART_RECV
#pragma GCC poison SIG_UART_DATA
#pragma GCC poison SIG_UART_TRANS
#pragma GCC poison SIG_ADC
#pragma GCC poison SIG_EEPROM_READY
#pragma GCC poison SIG_COMPARATOR
#pragma GCC poison SIG_2WIRE_SERIAL
#pragma GCC poison SIG_SPM_READY

#endif  /* !defined(__AVR_LIBC_DEPRECATED_ENABLE__) */

Maybe try adding a:

-D__AVR_LIBC_DEPRECATED_ENABLE__

to the pre-processor options if you insist on trying to maintain code with SIG_ vector names.

...A Google shows that some builds of Arduino on Linux have been caught out by this same thing (and the fact that some of the Arduino library code is old and still uses SIGNAL(SIG*) ) and that __AVR_LIBC_DEPRECATED_ENABLE__ has been used as a solution there too.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you! Thank you! Thank you!

My search for "SIG_INTERRUPT1" in iom8.h stopped after the #define reference. I did not search further to see your discovery at the end of iom8.h.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had the same problem and found the solution here (thanks guys!).

Just for clarify, the attached screen shows the symbol to be added (and it location).

Regards.

Attachment(s): 

Teach is learn twice. So, what do you think regarding learn again?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To be honest the "better" solution is to update the use of SIGNAL(SIG_*). It may just be "poisoned" now but could easily disappear completely shortly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

replace with following lines in atmel studio 6

 

#define UART0_RECEIVE_INTERRUPT   USART0_RX_vect
 #define UART1_RECEIVE_INTERRUPT   USART1_RX_vect
 #define UART0_TRANSMIT_INTERRUPT  USART0_UDRE_vect
 #define UART1_TRANSMIT_INTERRUPT  USART1_UDRE_vect

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's useful

A Chinese student.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I found this:

ISR(TIMER1_COMPA_vect)

AVR Modbus TCP/RTU