Well, some time ago I mentioned the above.
Last weekend I tried to implement the mbed as rom emulator.
The good news: It works
The bad news: it does not work from an interrupt...
I connected the mbed almost directly to the 8048 bus, using about every IO pin available.
D0-D7 (the Databus) is connected to 8 consecutive bits on port P0.4-P0.11
The lower 6 Addressbus bits A0-A5 are on P2.0-P2.5 the next 4 bits A6-A9 are on P0.15-P0.18 and finally A10 and A11 are on P1.30 and P1.31
nPSEN should be triggering the interrupt on the falling edge, I then have 1 usec to switch the bus to output and generate a databyte onto the databus, as soon as nPSEN rises again the databus is released.
This is (so far) my most optimized coding attempt by using direct addressing to set the port pins.
volatile uint32_t *myport0= (volatile uint32_t *) 0x2009c000;
volatile uint32_t *myport1= (volatile uint32_t *) 0x2009c020;
volatile uint32_t *myport2= (volatile uint32_t *) 0x2009c040;
// endless loop
while (1) {
// wait for PSEN to drop
while (*(myport0+5) & 2);
// set databus to output
*(myport0) |= DataBusMask;
// connect A0-A5 (P2.0-P2.5) A6-A9 (P0.15-P0.18) and A10/A11 (P1.30/P1.31) together
// and use that as address pointer (offset)
ad=(*(myport2+5) & 0x0000003FL) | ((*(myport0+5) & 0x00078000L)>>9) | ((*(myport1+5) & 0xC0000000L)>>20);
// now emit the appropriate data byte from testrom
*(myport0+7)=0x00000FF0L; // clear all 8 data bits of port0
*(myport0+6)=(*(testrom+ad))<<4; // set the 1 bits of byte on port0
// now wait for PSEN to rise again
while (!(*(myport0+5) & 2));
// set databus to input again
*(myport0) &= ~DataBusMask;
}
If I implement the code above as interrupt routine, starting on the falling edge of PSEN, it is too slow.
It seems it takes too long for the interrupt routine to start. The code above is fast enough (according to my oscilloscope). The 8048 runs fine on the generated bytes and does not miss a beat.
I had hoped the remaining time after PSEN rises (1.5 usec) could be used for other routines on the mbed or maybe even use a second interrupt on the rising edge to release the bus freeing even more cycles.
Any ideas how to speed up the interrupt response ?
Where can I find exactly how fast (in nanoseconds) the mbed (or LPC in fact) reacts to an interrupt ? Is it possible to optimize this in assembly. Can any port pin be used as NMI interrupt ?