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

Debugging with signal function

Hello!
I trying to simulate the signals given to the microcontroller. My special point is to start and stop a simple square wave. Everything works fine exept the SIGNAL KILL. After the "exec()" it is impossible to stop or reset the target program or to leave the debug mode of uVision.
There is no error message and the only way to leave is to use the Windows Task Manager.
I created a .ini file with the Function Editor.
Any ideas?

(thread6908 did help a lot, thanks to Gary Lynch!)

/* simulate the input (square wave) */
signal void CoolingWater (void)
{
    while (1)
    {                                  /* repeat forever       */
        PORT3 |= 0x80;                 /* set bit */
        swatch (0.0200);               /* delay */
        PORT3 &= ~0x80;                /* clear bit */
        swatch (0.0200);               /* delay */
    }                                  /* repeat               */
}
/* show output every time it changes */
/* start and stop signal function *
FUNC void ShowOutputs (void)
{
    printf ("Output  %04X %04X %04X %04X\n", ausgabe[0],ausgabe[1], ausgabe[2], ausgabe[3] );
    if (ausgabe[1] & 0x0002)
        if (waterOn==0)
        {
            waterOn=1;
            CoolingWater();                 /* start simulating impulses */
        }
    if (!(ausgabe[1] & 0x0002) && waterOn)
    {
        waterOn=0;
        exec ("signal kill CoolingWater");  /* stop simulating impuses --- CRASHES HERE--- */
    }
    if (ausgabe[0] & 0x0100)                /* if output is 1 ... */
    PORT3 |= 0x40;                          /* ...then  simulate input */
}


BS spiAusgabe,1,"ShowOutputs()"             /* breakpoint to start the user function */

  • If I remove the line with "exec()" from the .ini-file and enter the command "signal kill CoolingWater" at the debugger command line it works and I can continue the debugging process. But I'd like to have it automatically.

    The comment with the missing slash was added later. I have corrected it already.

    /* start and stop signal function */
    

  •             CoolingWater();                 /* start simulating impulses */
    

    To me, this looks suspicious. It just might call your signal function as if it were an ordinary one --- and since CoolingWater() contains an endless loop, it would never return from that.

    Did you try using "exec" for this?

  • Thank you for the hint, I changed it to

    exec ("CoolingWater()");
    


    There was no error message, but the simulator crashes, if it reaches this line. I could not leave the simulation like I descibed earlier.
    After changing it back to

    CoolingWater();
    

    it works.
    I also tried to define a button and stop the signal, this works fine:

    DEFINE BUTTON "Stop",    "SIGNAL KILL CoolingWater"
    

  • It is me again...
    Today I modified the "Hello world!" project to test the debug function and to get more experience with the simulator. The result: it works perfectly.
    In my application I'm using RTXtiny. This is possibly the reason of the strange behavior. To be continued...

  • Update:
    It runs without any problems with a small RTXTiny project - but my problem is still not solved.
    As a workaround (I did not want waste more time on it) I do not use "kill" command.
    I've created the simulation of my hardware (digital I/O, extern ADC, CAN, RS232). That took me some days and together with the belonging PC software makes the two cores of my PC glow ;-)
    But now I'm able to debug my program without having all that hardware stuff. With the help of com0com I even don't need a RS232 cable (see: com0com.sourceforge.net/)
    My impression is that only a few people are using this powerful but bad documented simulation tool.