Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
;
; variables
;
Dig_Sel equ 0x70 ; bit 7 is used to select digit
Temp equ 0x71 ;
;
org 0x0000
Reset
clrf STATUS ; force bank 0
movlw h'07' ;
movwf CMCON ; turn comparator off
bsf STATUS,RP0 ; bank 1
movlw h'FF' ;
movwf TRISA ; make Port A all inputs
movlw h'00' ;
movwf TRISB ; make Port B all outputs
bcf STATUS,RP0 ; bank 0
clrf Dig_Sel ; init Digit Select (B7 = 0)
Loop
movf PORTA,W ; get Lo input in b3..b0
btfsc Dig_Sel,7 ; low digit? yes, skip, else
swapf PORTA,W ; get Hi input in b3..b0
call SegData ; get segment data
iorwf Dig_Sel,W ; pick up digit select bit (b7)
movwf PORTB ; update display
movlw b'10000000' ; digit select bit mask
xorwf Dig_Sel,F ; toggle b7 digit select bit
goto Loop ;
I agree. It might also be helpful for those chaps building discrete logic clocks but the design does have some limitations. For example, it almost seems you'd need two versions, one with leading zero suppression, and one without, and I don't see an easy way to implement brightness control.ericgibbs said:It would be interesting if one of the OP's, who have been asking for bin2hex drivers gave it a shot. For about $2 its much more cost effective and has a smaller on board footprint than discrete ic's.
I agree. Here's a simple low overhead 8 bit DelayUS() sub-system (macro and subroutine) that could be used by those interested in experimenting with inter-digit delay time;ericgibbs said:If the refresh rate is too fast for some LED's a short inter LED delay would be easy to implement.
radix dec
;******************************************************************
; *
; DelayUS(8..1031), 4 MHz clock Mike McLaren, K8LH, Jun'07 *
; *
; requires the use of constant operands known at assembly time! *
; *
; 7 words, 0 ram variables, 14 bit core *
; ^^^^^^^^^^^ *
; the macro generates 2 instructions; *
; *
DelayUS macro delay ; parameter 8..1031
movlw delay/4-1
call Delay4Tcy-(delay%4)
endm
; *
; code for simulation testing; *
; *
SimTest DelayUS(1000) ; delay 'n' usecs
nop ; put simulator break point here
; *
;******************************************************************
nop ; entry point for (delay%4) == 3 |B0
nop ; entry point for (delay%4) == 2 |B0
nop ; entry point for (delay%4) == 1 |B0
Delay4Tcy
addlw -1 ; entry point for (delay%4) == 0 |B0
skpz ; |B0
goto Delay4Tcy ; |B0
return ; |B0
;******************************************************************
Loop
movf PORTA,W ; get Lo input in b3..b0
btfsc Dig_Sel,7 ; low digit? yes, skip, else
swapf PORTA,W ; get Hi input in b3..b0
call SegData ; get segment data
iorwf Dig_Sel,W ; pick up digit select bit (b7)
movwf PORTB ; update display
DelayUS(1000) ; delay 1 msec
movlw b'10000000' ; digit select bit mask
xorwf Dig_Sel,F ; toggle b7 digit select bit
goto Loop ;
Mike said:Eric (Ericgibbs) contacted me off list and he's got a much simpler and more elegant solution that doesn't involve the screwy Charlieplexed display wiring and code. His method uses your suggestion for using 1 pin to drive the common cathodes on both displays.
Mike said:Here's the first draft of the 16F628A firmware (untested). Hope to test it this coming weekend.
Mike