Hej Dr. Imre Bartfai. Tack fšr ditt meddelande 14:23 1999-10-20 +0200 enligt nedan: >Hi, > >why not: > ... > ClrW > MovWF PCLATH > CALL 4 > ... >as a Q&D solution. Then, of no particular IT flag set/enabled, then it is >yours. > >Regards, >Imre Thank you for your input. Just one thing: If I CALL 4 then I go there with the interrupt still enabled, so I can get an interrupt while in interrupt. Could get nasty. So we better turn it off first. PCLATH I take care of as usual in the interrupt. Just have to set a RAM flag first to tell the interrupt routines what service i want to run (it may happen i get another flag before getting to the routines). That would make... GIEoff BCF STATUS,GIE ;Shut off real interrupt BTFSC STATUS,GIE ;Fix the CPU bug... GOTO GIEoff CALL 4 ;Pretend interrupt occourred BSF MySoftwareInterruptIndicator ...And the interrupt gets reenabled by the RETFIE back here Nice :) A faster trick is of course to jump directly to the routine GIEoff BCF STATUS,GIE ;Shut off real interrupt BTFSC STATUS,GIE ;Fix the CPU bug... GOTO GIEoff ;Saving registers? *) CLRF PCLATH ;(often not needed, already if in page 0) ;might wanna set a flag or load W with something to process? CALL TheInterruptServiceWeWannaRunNow ...And the interrupt gets reenabled by the RETFIE back here *)If we are outside routines that store info in W, STATUS, FSR, PCLATH, then we do not need to save them, whis speeds up the call :) ::::::::::::::: But of course the simplest, and nicest solution i think is if we could guarantee that: BSF AnInterruptRequestFlagWeElseDoNotUse always works, without suspected possibility to overwrite an interrupt flag which get set by hardware during execution of the BSF. But as we normally use BCF TheInterrupFlagWeAreServiceing in the interrupt service, that would be the same problem. Grumble...! Now I got a serious problem, as I start suspecting that also using BCF during interrupt processing on a flag might owerwrite another flag in that byte if it get set between the read end rewrite cycles during execution of the BCF... Would happen very rarely, but makes it possible to miss an important interrupt!! Reading the manuals and the operation of the BSF/BCF this is exactly what we might expect!! But that is also a queestion about how the interrupt logic to set the flags look like, and the flags themselves. Mchip could have solved this by having pulse stretch logic to make sure the hardware set flag pulse is longer than the time between read and rewrite of read-modify-rewrite instructions. As they want to save silicon I wonder if they did this. I have not seen it commented or explained how the behaviour og BCF etc are taken care of regarding interrupt flags. Have anybody seen a note on this delicate matter? Comments please /Morgan Morgans Reglerteknik, HŠllekŒs, 277 35 KIVIK, SWEDEN tel +46(0)414-446620, fax -70331, mrt@iname.com