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
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