irin & Anything else!!!!!

shamu

Member
Hi all.

I am trying to use 'setint' triggered by a Hall effect switch, and 'irin' in the same program.

Each individual part of the program works on it's own, but when I put the two together only 'irin' works!

Can these two be made to work together, will 'irin' allow anything else to run at the same time as it?

Thanks in anticipation.



Code:
#picaxe 40X2
#no_data
#no_table

setfreq em16 ' This line sets th clock speed to 16 MHz.
             ' A 16MHz resonator needs to be connected to pins 13 & 14.

let dirsA = %11111111  ' Set port A as all outputs.
let dirsB = %11111111  ' Set port B as all outputs.
let dirsC = %11111001
let dirsD = %11111111  ' Set port D as all outputs.

'  This is the program for the 40X2 to read a decoded infrared signal on pin
' C.0 and place it in variable infravalue.

 high c.1 ' Pin 16 colour 1 
 high c.5 ' Pin 24 colour 2

SYMBOL infravalue = b10 ; define an infra variable

let outpinsA = %11111111
let outpinsB = %11111111
let outpinsD = %11111111

setint %0000000,%00000100,C

start:

  let outpinsB = %11111111
  let outpinsD = %11111111
  
  irin C.0, infravalue ; read input C.0 into infravalue
  
  If infravalue =10 then
    let outpinsB = %00000000
    pause 1000
    let outpinsB = %11111111
  end if

  If infravalue =20 then
    let outpinsD = %00000000
    pause 1000
    let outpinsD = %11111111
    pause 1000
  end if

  
goto start


interrupt: ' This is the routine triggered by the Hall effect on C.2
    let outpinsA = %00000000
    pause 1000
    let outpinsA = %11111111
    setint %00000000,%00000100,C
    return
 

westaust55

Moderator
Timeout as suggested by eclectic may help.
However you may miss interrupts while waiting for the timeout period or IR data if doing actions associated with the interrupt.
Nothing will guarantee 100% correct results but you could get a lot closer.

What is the IR sending device. Most remotes send the same signal/data several times while a button is pressed so if you miss one data packet you could successfully receive the next.

Another option may be to use interrupts on the IR input as well if you have control over the IR sender and can send a pre-pulse.
Then depending upon the source of the interrupt you code the program to act accordingly.
 
Top