I tried using IOC and DT interupt14 ,bas , but no success yet on what i was hopping , but it does compile with no errors !!!
1.setup DT_interupts as shown here at the start of code
Code:
INCLUDE "DT_INTS-14.bas"
INCLUDE "ReEnterPBP.bas"
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler GPC_INT,_GetIRcode, PBP, no
endm
INT_CREATE ; Creates the Interrupt Processor
ENDASM
2. setup gpo.0 as digital output
3. call sendcode routine , which then sends out data on gpio.0
4. i set up gpio.0 = 1 for an input and set IOC.0 =1 to turn on at end of sendcode routine
5. i then use int enable after the send routine back in main loop using '@ INT_ENABLE GPC_INT'
6. i ensure getircode routine has "@ INT_RETURN " at the end of the routine " see code"
7 i remove gosub getircode call from main prog loop , as it should now only be called when an interupt or data is present on the port gpio.0
8 main loop has nothing else in it for this test
to test i send an ir code and see if it is written to eeprom - eg did it get the code when data was on the input and was the routine called from the interrupt
but this is not working and the getircode sub does not get called
What am i missing to make it work , or will it not work this way as i thought it might
Code:
GetIRcode:
TRISIO.0 = 1 ' setup input=1,output=0 GPIO.0 = 1 to input
IOC.0=1 ' Set Change in Interrupt on GP0.0 for when it changes from high , when its a input in GetIR routine
PULSIN IR,1,Leader ' get leader high pulse time value in on GPIO.0 ( pulsin_max set to 4000 = 20ms )
IF Leader < 800 tHEN return ' look for 4500us high pulse below 4000us then its 2nd key area pulse or data/ address bits (800^ 5us= 4000us)
IF Leader > 960 tHEN return ' above 4800us then it no sig (460)
FOR X = 0 TO 31 ' grab 32 incoming pulses
PULSIN GPIO.0,1,leader ' now measuring high-going pulse widths
BtnVal(x) = leader/2 ' leader divide by 2 so Btnval(x) is byte (<255) not word value
NEXT X
z = 0 ' Z points to start range of byte
S = 7 ' S points to end range of byte
X = 0 ' start X at 0 to line up with BtnVal array
for Y = 1 to 4 ' Get in Array and decode 4 bytes from 32 bit pulses
T = 7 ' Set T to 7 so that it puts BtnVal(0) in to D7 location
FOR X = Z TO S ' sort 8 pulses of byte
IF BtnVal[X] > 120 THEN ' > 120 x (5uS *2) = > 1.2mS pulse period = 1 (150)
DByteTmp = DByte[Y] ' get into temp var
DByteTmp.0[T]=1 ' Set value to 0 or 1 , T reverses bit order of BtnVal(x) so byte has correct bin value to write byte
ELSE
DByteTmp = DByte[Y] ' get into temp var
DByteTmp.0[T]=0 ' Set value to 0 or 1 , T reverses bit order of BtnVal(x) so byte has correct bin value to write byte
ENDIF
DByte[Y] = DByteTmp ' get it back into DByte(y)
T = T - 1 ' T points to next MSB on loop
NEXT X
Z = x ' Z = X (0,8,16,24) points to start of next byte
S = 7 + X ' S (7,15,23,31) points to End of next DByte BtnVal offset to X
next Y ' loop for 4 bytes
' only save code if it differnat to stored IR code
x=1 ' ensure 1
for x = 1 to 4
if DByte[x] <> STDByte[x] then
write x,DByte[x]
endif
next x
@ INT_RETURN
return
regards
Sheldon
Bookmarks