Interrupt does not trigger

manie

Senior Member
Setup:
1. LCD/keypad module with 28x1 @ 8MHz (setfreq m8), will be the interruptor of
2. Main controller module with 40x1 @ 8MHz (setfreqm8).

Both setup to send/receive via Hserin/Hserout.
The 28x1 via portc 7/portc 6.
The 40x1 via portc 7/portc 6 (as per pinout diagrams).

Circuit:
28x1-----------------40x1
portc 4(out)----------input 6/leg29(in)
portc 5(in)-----------output 1/leg34(out)
Gnd(0V)-------------Gnd(0V)----------------power 0V

The voltage on 28x1 portc 4(out) when set high=4.95V. The pin is low (0V) beforehand.
This voltage appears on 40x1 input 6 when 28x1 pin goes high(also 4.95V).

Code for 28x1:Initialising
Code:
Init:					'initialize here

outpins=%00000000
high 7
portc = %00000000
setfreq m8				'freq @ 8mhz for 9600bd comms
setint %00100000 , %00100000	'interupt on pin 5 when high
Code for 28x1 to generate interrupt and send data when interrupt is acknowledged:
Code:
WireData:			'send new alarm setpoint to Main

'-----------------
'ON 40X1 MAIN
'int-out output pin 1
'int-in input pin 6
'hserin portC 7
'hserout portC 6
'-----------------

temb2=pin5					'pin5 = low normally
high portc 4				'output interrupt to Main
do until temb2<>0				'loop until interrupt confirm
	temb2=pin5
loop
low portc 4					'stop inter. signal				
sertxd("pin 5 = ",#temb2)
pause 10					'wait for main to get ready


if charcnt=218 then		'deg C setpoint
	hserout 0,("c")		'send what is comming
	pause 20
	hserout 0,(temb1)	'send ^C new setpoint="c"	
end if

if charcnt=226 then		'RH% setpoint
	hserout 0,("r")		'send what is comming
	pause 20
	hserout 0,(temb1)	'send RG new setpoint="r"
end if

return
Code for 40x1 to initialise:
Code:
Init:

hsersetup B9600_8,%00
setint %01000000,%0100000
goto main
Code or 40x1 when interrupt occurs:
Code:
Interrupt:			'check for interrupt from keypad module


tempb1=255
high 1		'signal int.request received
pause 50
low 1			'stop signal
hserin [500,main],200,1
pause 20
read 200,tempb2
select case tempb2
	case = "c"
		hserin [500,main],201,1
		pause 20
		read 201,tempb1
		gosub ChkForUpd_T
	case = "r"
		hserin [500,main],202,1
		pause 20
		read 202,tempb1
		gosub ChkForUpd_H
	case = "d"
		hserout 0,(t1,rh1,news,speed)
end select

setint %01000000,%0100000
sertxd("Interrupt request")
return
Both Interrupt: subroutines are the last routines in both programs(End of program as per Basic Command Manual).
What am I doing wrong here ?
 
Last edited:

hippy

Ex-Staff (retired)
setint %01000000,%0100000

Wrong number of bits / mis-match between mask and match value ?
 

lanternfish

Senior Member
As you are using the hardware serial in and out you won't need to have the 28X1 interrupt the 40X1. The serial work can take place in the background so that you only have to check the scratchpad to see if new data has arrived. The hserinflag is set every time data is received. If set, process and clear. If not, carry on. The manual gives a clearer explanation. Would help if we knew what each of the PICAXE's will be doing. Cheers
 

manie

Senior Member
Hippy: Thanks, there was a mismatch, however that was not the problem. I added a 10K pull-down to the interrupt input pin, still does not trigger.

Lantern: In the meantime I've gone the Hserin/out route. Problem is the 40x1 can be busy with something for quite a few seconds before checking the Hserinflag. The 40x1 sometimes must wait for user action before deciding to continue... during those wait periods, the LCD module must obviously also wait for response from the 40x1. It works, but is not smooth and is not elegant at all. I need the interrupt.

Could the interrupt pin on the 40x1 be damaged ? It sees either 0V (measured) when no interrupt request or it sees 4.95V when IRQ is on. At the LCD module side I don't know, tried to trigger an interrupt there by touching 5V lead to pin feed but nothing happened. Is there some delay or something I'm missing.

Otherwise, along with the "wait" period, the LCD module gets updates passed on to the Main controller and receives "current data" for display from the Main controller via Hserin/Hserout. The "dead" periods just does'nt look good (to me).
 

inglewoodpete

Senior Member
Manie,
I haven't tried to read or understand your code but, if you're trying to use interrupts and hSerial, have a look at the SetIntFlags command. It has a flag reserved for hSerial data.

Peter
 

hippy

Ex-Staff (retired)
Could the interrupt pin on the 40x1 be damaged ? It sees either 0V (measured) when no interrupt request or it sees 4.95V when IRQ is on.
The best approach there is to write a short test program which loops until interrupt and when it occurs flash a LED or use SERTXD to report it. That is, remove all the code except for the main loop and interrupt handler.

SetInt match,mask
Do
Loop

Interrupt:
SerTxd( "INTERRUPT", CR, LF )
Do : Loop While pinInterrupt = ?
SetInt match,mask
Return
 

manie

Senior Member
Lantern: That code has changed. The 28x1 code
Code:
hsersetup B9600_8,%01
and the 40x1 side code
Code:
hsersetup B9600_8,%01
works smoothly, no problems there.

Peter: I will look into teh "SetIntFlags command". Thanks

Hippy: Your suggested code: "Do : Loop While pinInterrupt = ?"... For what period (uSecs or Secs) should the interrupting processor keep the output high ? Does it matter how long ? Or is this just to demo the Interrupt response to the pin's state ? However, I will try that ASAP. I'm going to the chook-house farm tomorrow (400Km !). Proto installation of system. Still quite a bit to finish though.

Stan: The 433MHz on-site test is finally happening, with the "cotanga" off-course !
 

manie

Senior Member
Into the enclosure ! Quick cut-and-fit (maybe a little TOO quick), that darn Dremel cuts smooth but FAST ! Starting to take shape now...

The info you get reported when selecting "2" from Main Menu (see pics above)
 

Attachments

hippy

Ex-Staff (retired)
Re : Interrupt test

Yes, that is just to test it. Almost any decent length pulse from the other to generate the interrupt will do, or remove the chip and force interrupt by moving wire between 0V and 5V.

It's mainly to prove the pin works, the SETINT mask and match are right.
 

manie

Senior Member
Thanks Hippy, will try when I have time.Now we're off to the farm for the test/proto installation. Will let you guys know how it went.
 
Top