Shop OBEX P1 Docs P2 Docs Learn Events
LOCK Interrupts miss initial event(s) — Parallax Forums

LOCK Interrupts miss initial event(s)

Chip,

It looks like initial LOCK (and possibly EDGE) events are getting lost. In the following code, the first two events are not getting triggered.
dat
		org

		setb	dirb, #0	'indicates ISR activity
		setb	dirb, #1	'indicates main loop activity

		waitx	##25_000_000	'wait 1/2 second for INB to figure itself out

		setedg	#%1_11_00_0000	'lock, set or clear, index 0
		mov	ijmp1, #isr	'set up ISR
		setint1 #3		'edge-triggered event

loop		lockset #0		'set lock
		notb	outb, #1	'toggle GRN 1
		waitx	##50_000_000	'wait 1sec
		
		lockclr #0		'clear lock
		notb	outb, #1	'toggle GRN 1
		waitx	##50_000_000	'wait 1sec

		jmp	#loop		'repeat forever...


isr		notb	outb, #0	'toggle GRN 0
		reti1

However, if I move the ISR to a separate cog, then I only seem to lose the first event:
dat
		org	0

		coginit	#16, #@lock_test

		setb	dirb, #1	'indicates main loop activity		

		waitx	##25_000_000	'wait 1/2 second for INB to figure itself out

loop		lockset #0		'set lock
		notb	outb, #1	'toggle GRN 1
		waitx	##50_000_000	'wait 1sec
		
		lockclr #0		'clear lock
		notb	outb, #1	'toggle GRN 1
		waitx	##50_000_000	'wait 1sec

		jmp	#loop		'repeat forever...


		org	0
lock_test
		setb	dirb, #0	'indicates ISR activity

		setedg	#%1_11_00_0000	'lock, set or clear, index 0
		mov	ijmp1, #isr	'set up ISR
		setint1 #3		'edge-triggered event

.loop		jmp	#.loop		'loop forever

isr		notb	outb, #0	'toggle GRN 0
		reti1
Sign In or Register to comment.