Help 8051 assembly code seven segment counter

Thread Starter

moses912

Joined Jun 13, 2010
2
Hello, im using a c8051f330 microcontroller and im multiplexing a 4 digit seven segment display. Its common cathode setup. ok i got my code counting from 0 to 9 but all four digits are counting at the same time. I want to count from 0000 to 9999. I got the the seven segments common cathode and here is the code. Can some one help. Please i dont have the schematics just the code in assembly.


$NOMOD51

$include (c8051f330.inc) ; Include register definition file.

display1 equ P0.0
display2 equ P0.1
display3 equ P0.2
display4 equ P0.3


ORG 00H ; starting code memory location
SJMP MAIN ; execute main code

ORG 1BH ; start cord

MAIN: ANL PCA0MD, #NOT(040h) ; disable the WDT
MOV XBR1, #40H ; enable Crossbar
ORL P1MDOUT, #0FFh ; make port 1 output push-pull


MOV P1,#00H
LOOP:
MOV P1, #0BFH ; count 0 to 9
ACALL DELAYS
MOV P1,#86H
ACALL DELAYS
MOV P1, #0DBh
ACALL DELAYS
MOV P1,#0CFH
ACALL DELAYS
MOV P1,#0E6H
ACALL DELAYS
MOV P1, #0EDH
ACALL DELAYS
MOV P1,#0FDH
ACALL DELAYS
MOV P1, #007H
ACALL DELAYS
MOV P1,#0FFH
ACALL DELAYS
MOV P1, #0EFH
ACALL DELAYS

AJMP LOOP


DELAYS: ;1s DELAY
MOV R5,#10
D1:
CALL DELAY
DJNZ R5,D1
RET

DELAY: ;100ms DELAY
MOV R7,#200
D2:
MOV R6,#100
D3:
NOP
NOP
NOP
DJNZ R6,D3
DJNZ R7,D2
RET
END
 

retched

Joined Dec 5, 2009
5,207
It is probably a problem with the hardware. Can you draw up a schematic?

Use MSpaint or even a pencil and paper and scan it in or use a camera and take a picture of the drawing.

I have a feeling you have it wired improperly.

Are you using a 7seg driver?
 

Thread Starter

moses912

Joined Jun 13, 2010
2
no I'm not using a driver. I don't think its wired wrong because they all turns on its definitely a problem with the code. I got P0 defined as my digit selector but Its not multiplex in the code. I don't know how to do that. I was wondering if someone can help me?
 

Arm_n_Legs

Joined Mar 7, 2007
186
In multiplexing technique, you need to control the sequence the digits light up by controlling the logic of display 1 to display4. You did not implement this step in your program.
 
Top