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

Uvision 3 Simulator SIGNAL function cannot set IE1

I've been trying to get IE1 set from a SIGNAL all day. It seems just plain broken. Please show me what I am doing wrong...

Here is a sample main built for Synopsys DW8051, default New Project settings.

IDE-Version:
µVision3 V3.80
Copyright (c) Keil Elektronik GmbH / Keil Software, Inc. 1995 - 2009

Tool Version Numbers:
Toolchain: PK51 Prof. Developers Kit Version: 8.18
Toolchain Path: C:\Keil3\C51\BIN\
C Compiler: C51.Exe V8.18
Assembler: AX51.Exe V3.06h
Linker/Locator: LX51.Exe V4.39
Librarian: LIBX51.Exe V4.24
Hex Converter: OHX51.Exe V1.36e
CPU DLL: S8051.DLL V3.65
Dialog DLL: DCore51.DLL V2.68

----------------------------- main.c -----------------------

#include <REGDW.H>

volatile unsigned char pdata toggle;

void main ( void ) {
  unsigned char temp;
  toggle = 0;

  ET1 = 1; // Enable timer 1 interrupt
  EX1 = 1; // Enable ext 1 interrupt
  EA  = 1;  // Global interrupt enable

  while (1) {
    if (toggle >= 2) {
      toggle = 0; // <<< Never reached
    } else if (toggle == 1) {
      toggle--;
    }
    temp++;
    temp++;
    temp++; // Waste time
  }
}

void timer1Interrupt (void) interrupt 3 using 3 {
  toggle |= 1;
}

void ext1Interrupt (void) interrupt 2 using 2 {
  toggle |= 2;
}


----------------------------- IE1.ini -----------------------


SIGNAL void timerHandler () {
  printf("Starting ad hoc timer\n");
  while (1) {
    // Period = 100ms
    swatch (0.1);
    printf("Firing TF1\n");
    TF1 = 1;
  }
}


SIGNAL void ei1Handler () {
  printf("Starting ad hoc external event 1\n");
  while (1) {
    // Period = 40ms
    swatch (0.04);
    printf("Firing IE1\n");
    IE1 = 1;
  }
}

timerHandler();
ei1Handler();


----------------------------- Command Output -----------------------
...
timerHandler();
Starting ad hoc timer
ei1Handler();
Starting ad hoc external event 1

LA 'toggle
Firing IE1
Firing IE1
Firing TF1
Firing IE1
Firing IE1
...

But a breakpoint on the second "toggle = 0" never fires. I've proven to myself many ways that this should work. But it does not. If I click on IE1 in the Interrupt window it does work.

Why can't I set IE1 from a SIGNAL function?

  • I've proven to myself many ways that this should work.

    Alas, that proof was wrong.

    What you should do to trigger this interrupt is to actually simulate what would trigger this interrupt in real life, too: a status change that the corresponding port pin. There's even a complete example in the documentation (see uVision User's Guide --> Simulation --> Digital Input --> Interrupt Signal)

  • I forgot something. Another problem with this code is that you may be putting a bit too much faith in your assumption that the compiler won't see through this

        if (toggle >= 2) {
          toggle = 0; // <<< Never reached
        } else if (toggle == 1) {
          toggle--;
        }
    
    

    and optimize it to the equivalent

    toogle = 0;
    


    , in which case it would not even generate code for the line you're trying to stop at.

  • Thanks for the response...

    I've been working with customer support a bit and they also got me on the right path. I do appreciate the input.

    Your port example is on the right path, I did not appreciate the concept of Peripheral Registers and VTREGs. The Synopsys DW8051 is an IP core and I was not aware that the core I/O were exposed as VTREGs. These allow me to directly manipulate the INT1 input pin (akin to your PORT pin.)

    Somehow the IE1 assignment did not trigger the interrupt since it is likely downstream from the interrupt generator in the DW8051 simulation model. The pin itself is what generates the interrupt.

    Changing

      IE1 = 1;
    

    to

      // Generate active low pulse on INT0n pin
      INT1PIN = 0; // Real h/w pin is int0n (inverted)
      swatch (0.000001); // hack - will be cleared by peripheral h/w in application
      INT1PIN = 1;
    

    PS: I did verify toggle = 0; != toggle--; in the disassembly, I would not use this in customer code.

    Thanks for the clues. The forum is a great resource. My biggest mistake was trying to extend the timer overflow example to an INT pin as I did not realize the chip (core) I/O were fully exposed.