Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Binary input Hex dispaly (7 segment LED)?

Status
Not open for further replies.
This will do what you require.
Code:
Display	swapf   PORTA,W         ; W = hi nybble in b3..b0 bits    |B0
        btfss   DigSel,7        ; left digit? yes, skip, else     |B0
        movf    PORTA,W         ; W = lo nybble in b3..b0 bits    |B0
        andlw   b'00001111'     ; mask off upper 4 bits           |B0
        call    SegData         ; get segment data in W		  |B0
        iorwf   DigSel,W        ; add digit select bit in b7      |B0
        movwf   PORTB           ; display new digit               |B0
        DelayUS(7000-23)        ; 8-msecs including loop time     |B0
;               ^ changed so total loop time is the same.

[COLOR="Blue"]	clrf	PORTA		;clear the output latches
	bsf	STATUS,RP0	;bank 1
	clrf	TRISA		;make port A output
	bcf	STATUS,RP0	;bank 0
	DelayUS(1000)		;pause
	bsf	STATUS,RP0	;bank 1
	movlw	0xff
	movwf	TRISA		;make port A input
	bcf	STATUS,RP0	;bank 0[/COLOR]
	
        movlw   b'10000000'     ; mask for digit select bit       |B0
        xorwf   DigSel,F        ; toggle b7 digit select bit      |B0
        goto    Display         ; loop forever                    |B0

I've added the bit in blue. By altering the delay values (1000 & 7000) you should be able to find a compromise between drawing enough current and the pic not getting too warm.

Mike.
 
hi Tom, ttebeau...

You should start a NEW thread for your query, putting it here will cause confusion.:)
 
Thanks Pommie- appreciate it!

I'll try the program tonight and experiment with the delays.

The (totally unanticipated) problem with the current has been a bit of a nightmare- hopefully this will put it to bed once and for all!

Thanks again- I'll post back as soon as I've tried it.

-DAlmation.
 
Okay- I'm getting somewhere now.

I wont for a minute pretend to understand why, but after loads of experimenting I have came up with something...

When I set the delays to (7999-23) and (1), it seems to work, but obviously the display timings are totally out of whack (toggling between the digits just under twice per second).

I am going to read my "pic projects tutorial" book a bit more to see if I can figure out what those timings actually mean to the functioning of my circuit.

Is it because its drawing a tiny bit extra current or is it taking more readings? I hope to figure it out.

I'm feeling very concious of being spoon fed here- but I really am trying to learn as I go.

Thanks again- I'll keep at it.

-DAlmation.
 
Last edited:
dalmation said:
When I set the delays to (7999-23) and (1), it seems to work, but obviously the display timings are totally out of whack (toggling between the digits just under twice per second).
-DAlmation.

I think Mikes delay macro cannot handle very low values like 1 and consequently the delay time is very long.

Try changing the delay values so that the second delay is the longer one and see if that helps. The values 1000-23 and 7000 would set the port to output 87% of the time.

It would be worth measuring the current now (with the slow update) as this will give you the worst case.

Mike.
 
thanks- I will.

Not WORST case, though- the problem with the eeproms powering down to sleep mode doesnt happen with 7999/1 delays (which was the initial problem). I just need to figure out exatly what it is about this new setup that has allowed it to work- then I can hopefully keep that aspect the same, but fix the display.

Its 2am here- I'll get some sleep and continue tomorrow.

-Thanks again.

-Dal.
 
Pommie said:
I think Mikes delay macro cannot handle very low values like 1 and consequently the delay time is very long.
The parameter range for the DelayUS() routine is 16..262159 (it's in the program listing). A parameter of '1' is out of range...

Seems you need to experiment with timing values while trying to figure out just how long and how often you need to drive those bus pins... Mike's (Pommie's) code looks fine though I would do it a little differently.

Code:
;
;  setup ports and display sub-system variables
;
        bsf     STATUS,RP0      ; bank 1                          |B1
        movlw   h'FF'           ;                                 |B1
        movwf   TRISA           ; make Port A all inputs          |B1
        clrf    TRISB           ; make Port B all outputs         |B1
        bcf     STATUS,RP0      ; bank 0                          |B0
        clrf    DigSel          ; init b7 digit select bit        |B0
        [COLOR=RoyalBlue]movlw   TRISA           ; address TRISA (in bank 1)       |B0
        movwf   FSR             ; setup for indirect access       |B0
[/COLOR];
;  display loop (8 msecs, 50% duty cycle, 62.5 Hz refresh rate)
;
Display
        swapf   PORTA,W         ; W = hi nybble in b3..b0 bits    |B0
        btfss   DigSel,7        ; left digit? yes, skip, else     |B0
        movf    PORTA,W         ; W = lo nybble in b3..b0 bits    |B0
        andlw   b'00001111'     ; mask off upper 4 bits           |B0
        call    SegData         ; get segment data in W           |B0
        iorwf   DigSel,W        ; add digit select bit in b7      |B0
        movwf   PORTB           ; display new digit               |B0
        DelayUS(4000-26)        ; 4-msecs including loop time     |B0
        [COLOR=RoyalBlue]clrf    PORTA           ; clear PORTA output latch        |B0
        clrf    INDF            ; setup PORTA all outputs         |B0
        DelayUS(4000)           ; 4-msecs                         |B0
        comf    INDF,F          ; setup PORTA all inputs          |B0
[/COLOR]        movlw   b'10000000'     ; mask for digit select bit       |B0
        xorwf   DigSel,F        ; toggle b7 digit select bit      |B0
        goto    Display         ; loop forever                    |B0
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top