This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problems with signal(): "error 99, line 37: signal() already activated"

Hi,

I'm trying to generate a non-trivial pulse train using the debug scripting language, and I keep getting this error 99. Below is the script that generates the pulse. Whenever I start the script, I get this error from the title. Line 37 is the second call of the my_swatch() in the IR_send_mark function. I start the script by typing "IR_send_cmd(11)". Any hints?

// IR signal is fed to P3.2
DEFINE int IR_pin;
IR_pin = 2;

// duration of bits sent over the IR channel
DEFINE float low_bit;
low_bit=421.0e-6; // 421 us
DEFINE float high_bit;
high_bit=711.0e-6; // 711 us
DEFINE float start_bit;
start_bit=1184.0e-6; // 1184 us
DEFINE float stop_bit;
stop_bit=1184.0e-6; // 1184 us
DEFINE int IR_cycles_cnt;
IR_cycles_cnt= 6; // IR cycles in the IR mark
//DEFINE float instruction_time;
//instruction_time = ( (1/11.0592e6) * 12)

PORT3 |= (1 << IR_pin);  // initialize to high on the start of the debugger

SIGNAL void my_swatch(float pause)
{
   swatch(pause);
}

FUNC void IR_send_mark (void)
{       int i;

        i=0;
        while (i<IR_cycles_cnt) // cycles in the IR mark
        {
      PORT3 &= ~(1 << IR_pin);
          my_swatch(13.158e-6); // half of the 38 kHz cycle
      PORT3 |= (1 << IR_pin);
          my_swatch(13.158e-6); // half of the 38 kHz cycle
          i++;
        }
}

FUNC void IR_send_bit (float duration)
{
    IR_send_mark();
    PORT3 &= ~(1 << IR_pin);  // pull low to start the signal
        my_swatch(duration);         // hold low
    PORT3 |= (1 << IR_pin);   // return to high

}

FUNC void IR_send_byte(unsigned char byte)
{  int i;

   i=0; // 8 bits in byte, count downwards so that the MSB goes out
   while (i < 8)
   {  if (byte & (1<<(7-i)))
        IR_send_bit(high_bit);
      else
        IR_send_bit(low_bit);
      i++;
   }
}

FUNC void IR_send_cmd(unsigned int cmd)
{
  IR_send_bit(start_bit);
  IR_send_byte(cmd >> 8);
  IR_send_byte(cmd && 0xff);
  IR_send_bit(stop_bit);
}

Parents
  • The error is exactly what the message says it is: you're repeatedly trying to start a SIGNAL function, but that makes no sense. Once started a SIGNAL continues all by itself in the background.

    What's the point of writing your own version of swatch(), anyway? Why not just call it by its usual name?

Reply
  • The error is exactly what the message says it is: you're repeatedly trying to start a SIGNAL function, but that makes no sense. Once started a SIGNAL continues all by itself in the background.

    What's the point of writing your own version of swatch(), anyway? Why not just call it by its usual name?

Children
  • Note that my signal function doesn't contain an endless loop. I expect it to terminate when it returns and hence be removed from the signal functions' queue. It is called repeadetly, but each subsequent call occurs only after the previous call is finished. So there should be no active signal function at the time of subseqent call, right?

    The point of having my_swatch is not really relevant, it is simply to localise the swatch() call in a single function, so that I can make changes more easily (like replacing swatch with twatch, or I have even tried to do exec("SIGNAL KILL my_swatch") in the calling func after the call to my_swatch(), but this doesn't work either).

  • I expect it to terminate when it returns and hence be removed from the signal functions' queue.

    Expectations are usually wrong.

  • So what exactly is this function executing after the end of function is reached?

    Any suggestions how to re-write my signal generation code so that it actually works?