Disabling ISR during Serout
I may be trying to do something not possible or inadvisable. Simply I need to send out two byte of serial data , almost any speed will be fine , the faster the better. I need this to be done while watching a dozen IR transistors. The transistor pins or monitored In the ISR. That part works fine. As predicted the ISR screws up my serout Command, sometimes it work some times it does not. Can I simply disable the ISR during serout subroutine? Timing should not be a problem As the pulses on from the transistors last at least 200 ms, plenty of time to send out a few bytes. I have tried screwing around with the option reg. With No luck. Here Is my test code It just motors one transistor.
' =========================================================================
'
' File...... SingleFlakeTest.SXB
' Purpose... SX/B Programming Template
' Author....
' E-mail....
' Started...
' Updated...
'
' =========================================================================
' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------
DEVICE SX48, OSCXT2
FREQ 50_000_000
' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------
SOutA PIN RB.0 OUTPUT PULLUP
Mt1Front PIN RD.0 INPUT cmos
Mt1Back PIN RD.1 INPUT cmos
' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------
AllFWD CON %11111111
AllRVS CON %00000000
BUAD CON "T19200"
FwdMt1 CON $C6
MaxSpd CON $7F
ZeroSpd CON $0
Front CON 1
Back CON 0
ACT CON 0
notact CON 1
LmRs CON 1800
WaitTime CON 3000
' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
i VAR Byte
TempA VAR Byte
TempB VAR Byte
PosFlagFT VAR BIT
PosFlagBK VAR BIT
NextPos VAR BIT
MtNum Var BYTE
SPED VAr BYTE
' -------------------------------------------------------------------------
INTERRUPT 1000000
' -------------------------------------------------------------------------
ISR_Start:
Serout SoutA,buad, MtNum
Serout SoutA,buad, SPED
IF Mt1Front = ACT THEN
PosFlagFT = ACT
Else
posFlagFT =NotAct
ENDIF
Watch PosFlagFT
ISR_Exit:
RETURNINT
' =========================================================================
PROGRAM Start
' =========================================================================
Pgm_ID:
DATA "SX/B Template", 0
' -------------------------------------------------------------------------
' Subroutines / Jump Table
' -------------------------------------------------------------------------
GoFront SUB 0
GOBack SUB 0
Wait SUB 0
MotCom SUB 2
' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------
Start:
OPTION = $88
Serout SoutA,Buad, FwdMt1
Serout souta,buad, zeroSpd
PAUSE 2000
Main:
'
DO
GoFront
Wait
'GoBack
'Wait
LOOP
GOTO Main
' -------------------------------------------------------------------------
' Subroutine Code
' -------------------------------------------------------------------------
SUB GoFront
MotCom FwdMt1, MaxSpd
PAUSE LmRs
DO While PosFlagFt = NotAct
IF PosFlagFt = ACT THEN
MotCom FwdMt1, ZeroSpd
ENDIF
LOOP
ENDSUB
SUB GoBack
MotCom FwdMt1, MaxSpd
PAUSE LmRS
DO While PosFlagbk = 0
If posFlagBK = act THEN
MotCom FwdMt1, ZeroSpd
ENDIF
LOOP
ENDSUB
SUB Wait
PAUSE WaitTime
ENDSUB
SUB MotCom
'Code to diable ISR
TempA = __PARAM1
TempB = __PARAM2
SEROUT SOutA,Buad, TempA
SEROUT SOutA,Buad, TempB
'Code to enable ISR
ENDSUB

Comments
Just read the pins inside the main loop.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A government big enough to give you everything you want, is big enough to take away everything you·have."·· Thomas Jefferson
"It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter
www.iElectronicDesigns.com
·
To be honest, I really couldn't figure out what your code wants to do as it's all over the place and seems to be bashed together from parts you've found elsewhere (that's okay, we all have differnent learning styles). In the program that I've supplied all 12 sensors (I'm assuming they're active-low) are scanned and with a bit of bit-mashing you end up with a couple of bytes that will have 1 in a bit position of a sensor that went from off-to-on. There front and back sensor elements for a given channel are put together and a stacked IF-THEN structure lets you decide what to do with the new inputs.
Hopefully, at least some of it will be useful