interrupt 20x2

ColinP

New Member
Hi – I have a problem with using interrupts on the 20x2 – I am not sure what I am doing wrong. I have a simple vehicle with a line detector which must stop when it trundles over a white line ( this produces a high to low transition on the detector output). I use the normal ‘standard’ line detector module which works fine and an L293D motor control chip which also works fine. The detector is on C.3 – the following code works -

high b.7,b.5 ; set motors forwards
low b.4,b.6

loop1:
if pinc.3=0 then stopit ; triggered by detector running over the white line
goto loop1

stopit:
low b.4,b.5,b.6,b.7 ; motors off
serout b.2,n2400,("triggered") ; message on LCD

putting c.3 onto an interrupt – the motors never turn on - no message on LCD

setint %00000000,%00001000,c
high b.7,b.5
low b.4,b.6

interrupt:
low b.4,b.5,b.6,b.7
goto loop1
return

loop1:
serout b.2,n2400,("triggered")
goto loop1

Putting the forward motor control instructions into a loop works! The buggy goes forwards and the interrupt triggers a stop and the message on the LCD

setint %00000000,%00001000,c

loop1:
high b.7,b.5
low b.4,b.6
goto loop1

interrupt:
low b.4,b.5,b.6,b.7
goto loop2
return

loop2:
serout b.2,n2400,("triggered")
goto loop2

I am not sure why this happens - I am probably missing something pretty basic any help gratefully appreciated.

Colin
 

hippy

Ex-Staff (retired)
setint %00000000,%00001000,c
high b.7,b.5
low b.4,b.6

interrupt:
low b.4,b.5,b.6,b.7
The program falls through initialisation straight into interrupt so the motors are turned on but only for a short period, then turned off again.

That's why adding putting a GOTO after the HIGH/LOW commands work while this doesn't.
 

srnet

Senior Member
Well unless you let the call to the Interrupt routine see the matching return, the processors going to run out of stack space at some point, I presume.
 
Top