P2: pin output question
potatohead
Posts: 10,261
Here is a short program that writes the counter to some of the output pins with LED's attached on the DE2 board. Edited because I pasted the wrong code. Sorry. Here are the correct programs:
What am I missing here? No combination of AND appeared to work for me. ??? I tried making the outmask value all ones too.
' Terasic DE2-115 Prop2 LED Blinker
' ------------------------------------
' This one is broken, and I don't know why
DAT
org
neg dirb, #1 'make the port B I/Os outputs
:loop getcnt A 'fetch lower 32 bits of global counter
shr A, #16 'shift away the fast incrementing digits
and A, outmask 'zero lower bits
mov pinb, A 'write slow ones to LED's on DE2 board
jmp #:loop 'keep doing it!
A res 1 'storage
B res 1
outmask long $00_00_FF_00 'write higher bits only
' Terasic DE2-115 Prop2 LED Blinker
' ------------------------------------
' This one works!
DAT
org
neg dirb, #1 'make the port B I/Os outputs
:loop getcnt A 'fetch lower 32 bits of global counter
shr A, #24 'shift away the fast incrementing digits
shl A, #8
mov pinb, A 'write slow ones to LED's on DE2 board
jmp #:loop 'keep doing it!
A res 1 'storage
What am I missing here? No combination of AND appeared to work for me. ??? I tried making the outmask value all ones too.

Comments
Why not use this that way
000011 001 1 CCCC nnnnnnnnn 011001010 SETF #n 'Configure field mover with 0..511 1 neg dirb, #1 'make the port B I/Os outputs SETF #XX 'Configure field mover with D 1 000101 000 0 CCCC DDDDDDDDD SSSSSSSSS MOVF D,S 'Move field from S into D 1 instead of shr A, #16 'shift away the fast incrementing digits and A, outmask 'zero lower bits mov pinb, A 'write slow ones to LED's on DE2 board