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); }
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?