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)