DRVH instruction causes DIRx issues

Hi Chip
The last few days I've been trying to hunt down a weird program issue and discovered an issue with the DRVH instruction.
On their own DRVH seem to work Ok but any instructions that access the releveant DIRx register goes weird.
Here's some code snippets that demonstrate the issue.
'code_a & code_e are the only code snippets that work as expected.

dat	org

	jmp	#code_a

code_a	drvh	#32
	drvh	#33
	drvh	#34
	drvh	#35		'all leds on as expected
	jmp	#$

code_b	drvh	#32
	drvh	#33
	drvh	#34
	drvh	#35
	bitl	dirb,#1		'turns all leds off ????????
	jmp	#$

code_c	drvh	#32
	drvh	#33
	drvh	#34
	drvh	#35
	or	dirb,#0		'turns all leds off ????????
	jmp	#$

code_d	drvh	#32
	drvh	#33
	drvh	#34
	drvh	#35
	or	dirb,#%110000	'turns all leds off ????????
	or	outb,#%100000	'turns led #5 on as expected
	jmp	#$

code_e	bmask	dirb,#3
	bmask	outb,#3
	or	dirb,#%110000	'all leds remain on as expected
	or	outb,#%100000	'turns led #5 on Ok
	jmp	#$

code_f	drvh	#32
	drvh	#33
	drvh	#34
	drvh	#35
	bitl	dirb,#33	'turns all leds off ????????
	jmp	#$

I went back to V16 and the issue is still there if that helps.
Sorry to get you back to Quartus ;)
Melbourne, Australia

Comments

  • 6 Comments sorted by Date Added Votes
  • I'm not that familiar with the P2, but I think there's an issue with your logic in code_c and code_d.

    You're attempting to use
    or
    
    instructions to turn off bits. You should be using
    andn
    
    instead.

    Or'ing a bit with zero doesn't change it.
    Tulsa, OK

    My OBEX objects:
    AGEL: Another Google Earth Logger
    DHT11 Sensor

    I didn't do it... and I promise not to do it again!
  • That's what Oz is pointing out. He's pointedly not trying to turn them off but they turn off anyway.
    $50,000 buys you a discrediting of a journalist
  • evanh wrote: »
    That's what Oz is pointing out. He's pointedly not trying to turn them off but they turn off anyway.
    wmosscrop, evanh is correct!
    	or	dirb,#0		'turns all leds off ????????
    
    This shouldn't change the dira register at all.

    Melbourne, Australia
  • Dave HeinDave Hein Posts: 5,235
    edited July 17 Vote Up0Vote Down
    If you add a "mov dirb, #15" before the failing cases they will now work. I suspect that reads are performed from the shadow ram, and a drvh is not setting the shadow ram, whereas a "mov dirb" sets both the dirb register and the shadow ram. A drvh must set both dirx and outx, so it's not possible to set both shadow rams. At least that's my theory. If that's the case this limitation should be documented.

    EDIT: I tried the following code, and all the LEDs are lit. This is consistent with the theory that drvh/flth doesn't set the shadow ram, and that the shadow ram is accessed on reads.
    code_c
            mov     dirb,#15
    	flth	#32
    	flth	#33
    	flth	#34
    	flth	#35
    	or	dirb,#0		'turns all leds on ????????
    	jmp	#$
    
  • Hmmmmmm ... makes sense ... tricky. Lots of details all round to document. Chip has his work cut out for ... forever.
    $50,000 buys you a discrediting of a journalist
  • jmgjmg Posts: 10,206
    Dave Hein wrote: »
    If you add a "mov dirb, #15" before the failing cases they will now work. I suspect that reads are performed from the shadow ram, and a drvh is not setting the shadow ram, whereas a "mov dirb" sets both the dirb register and the shadow ram. A drvh must set both dirx and outx, so it's not possible to set both shadow rams. At least that's my theory. If that's the case this limitation should be documented.

    Nicely spotted.
    Could this not be fixed, so reads do not access shadow ram, but the real value instead ?

Sign In or Register to comment.