Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need "C" language code from this assembley language for this same circuit diagram

Status
Not open for further replies.

hardik.patel

Member level 5
Joined
Aug 15, 2012
Messages
94
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
2,008
Need "C" language code from this assembley language for this same circuit diagram

Hi all experts,

nowdays i m working with led dot matrix display using 8051. in which what i want to do is....i want to transmit a string of character by serial UART and display that received string on led dotmatrix display. i had one circuit and a code which is 100% ok but problem is ...it is in assembley language .so please any one here who can help me to convert it in a 'C' language??

(Atleast, if any1 can give me suggest a code & circuit related to display on 8 or more module of (8x8 or 5x7 or 8x10) dot matrix display of any moving character..than i can able to attach it with a serial function.)

Even if any1 had their own circuit diagram or code ..please its also help me lot.

here i am sending you my (.asm) code for your reference and circuit also.


Thanx to all in advance.


Code:
;Cascadable 8 char dot matrix display

;written by zuisti (shiftregs: 5 x hc595)


CommonCathode	equ	1	;for Proteus simulation, else common anode and
;CommonCathode	equ	0	;in the reality high current drivers needed

	DSEG

CCount	DATA	20H		;counter for received chars
FPos	DATA	21H		;First Pos in the received string
NPos	DATA	22H		;Next module's first Pos (last pos + 1 here)

c0	DATA	23H		;for first char (0) storage
c1	DATA	24H		;char 1
c2	DATA	25H		;char 2
c3	DATA	26H		;char 3
c4	DATA	27H		;char 4
c5	DATA	28H		;char 5
c6	DATA	29H		;char 6
c7	DATA	2AH		;char 7

	CSEG

	ORG	0000H

;89c2051 HW inic (timers, Usart)

	MOV	SP,#70H
	MOV	IE,#90H		;enable serial IT
	MOV	IP,#10H		;serial IT high prioritat
	MOV	SCON,#50H	;USART mode 1
	MOV	TMOD,#20H	;Timer 1 Mode 2, no Timer 2
	MOV	PCON,#80H	;SMOD = 0, no divide /2 
	MOV	TH1,#0F4H	;9600 baud with 22,1184 MHz clock

	SETB	TR1		;start Timer 1
	CLR	TI		;clear transmit IT flag

	ajmp	DisplayInic

RetiR:
	reti			;restore HW IT system 

	ORG	0023H

;Serial Interrupt Vector

SerIN:
;	PUSH	ACC
;	PUSH	PSW
;	PUSH	B		;it is a pseudo-IT_routine, no save 

	MOV	A,SBUF		;get the received char
	clr	C
	SUBB	A,#20H		;a displayable char is min. 20H (space)
	jnc	Ser0
	CJNE	A,#(0DH-20H),SerEnd	;press Enter to DisplayInic

DisplayInic:
	ORL	P1,#07H		;swich off all lines

; read the position switch state to determine the module's display position
; in the received string (from-to: 0...7, 8...15, 16...23 and so on)
; max 16 (0 ... 15) 8_char_modules

	MOV	A,P3		;get position switch state (P3.2 ... P3.5)
	ANL	A,#111100B	;only the switch inputs (states * 4)
	rl	A		;states * 8
	MOV	FPos,A		;First pos for this modul
	add	A,#8
	MOV	NPos,A		;Next modul's first Pos (last pos + 1 here)

	clr	A
	MOV	c0,A		;char 0 cleared (0 + 20h = space)
	MOV	c1,A
	MOV	c2,A
	MOV	c3,A
	MOV	c4,A
	MOV	c5,A
	MOV	c6,A
	MOV	c7,A
	dec	A
	MOV	CCount,A	;inic FFH, after first incr: 0
	AJMP	SerEnd

Ser0:
	inc	CCount		;incr the received character counter
	cjne	A,#61H,Ser1	;compare the char with 61H (81h-20h)
Ser1:
	jc	Ser2		;if C (char <= 80h), good
	mov	A,#("?"-020H)	;below 60(80)h subst with a "?"
Ser2:
	mov	B,A		;save the char
	mov	A,CCount
	cjne	A,NPos,Ser3	;compare the counter with NPos (NextPos) 
Ser3:	cpl	C		;C = not C
	jc	SerEnd		;if C, not for this module
	subb	A,FPos		; Counter >= FirstPos ?
	jc	SerEnd		; if C, not for this module
	add	a,#c0		;c0 is the place of the char 0 (first)
	mov	R0,A		;for indirect storing to R2 ... R7
	mov	@R0,B		;store the char
SerEnd:	
	CLR	RI		;clear receive IT flag

;	POP	B
;	POP	PSW
;	POP	ACC
;	RETI

; the SerIn routine doesn't return here, it continues with a new display loop

	MOV	SP,#70H		;to this, first restore (clear) SP
	acall	RetiR		;then signalize IT end (call a reti instr. only)

	CLR	P1.6		;reset clock and store bits
	CLR	P1.5		;to setup for positive pulses

	jc	DisplayLoop	;C is set (1) here if the display not changed  
	ORL	P1,#07H		;switch off all lines for the changed line out 

DisplayLoop:
	MOV	B,#7		;7 lines

LineLoop:
	mov	R1,#c0		;the first char is in c0 (sum 8 chars)
	dec	B		;the lines are numbered as 6...0

CharLoop:
	mov	A,@R1		;indirect get the next char (from c0 ... c7)

; get the actual line pattern of the char in A from table BITMAP

	RL	A		;calculate the DPTR for access to the table
	RL	A
	RL	A		; x 8 (8 bytes/char)
	MOV	DPH,A		;temporaly save this
	ANL	A,#11111000B	;get the highest (was lowest!) 5 bits only
				;to calculate the offset in BITMAP
	ADD	A,#LOW BITMAP	;assume the address of the BITMAP (Carry !!)
	MOV	DPL,A		;DPL is ready
	MOV	A,DPH		;restore the shifted char value
	ANL	A,#00000111B	;now the 3 lowest (was highest!) bits remain
	ADDC	A,#HIGH BITMAP	;add to high BITMAP with C to compute DPH
	MOV	DPH,A		;DTPR is pointing now to the char's first byte
	mov	A,B		;set the additional offset  to line no
	MOVC	A,@A+DPTR	;get the pattern

;the pattern is clocked out to the 5(*8) stage shift reg
;in A the displayed bits are 4 ... 0 only (shifted out in this order)

if	CommonCathode
	cpl	A		;the LED anode expected 1 to switch on
endif

	MOV	C,ACC.4		;move A.4 to Carry
	MOV	P1.7,C		;out C to Data pin
	SETB	P1.6		;generate a positive clock pulse
	CLR	P1.6		;end of pulse

	MOV	C,ACC.3		;A.3
	MOV	P1.7,C
	SETB	P1.6
	CLR	P1.6

	MOV	C,ACC.2		;A.2
	MOV	P1.7,C
	SETB	P1.6
	CLR	P1.6

	MOV	C,ACC.1		;A.1
	MOV	P1.7,C
	SETB	P1.6
	CLR	P1.6

	MOV	C,ACC.0		;A.0
	MOV	P1.7,C
	SETB	P1.6
	CLR	P1.6

	inc	R1		;next reg to ind. addressing of a char
	cjne	R1,#(c7+1),CharLoop	;but max. c7 !!

	MOV	A,B		;the whole line is shifted out, line no to A
	ANL	P1,#0F8H	;to prepare the line decoder (138) outputs
	ORL	P1,A		;to switch this line on

	SETB	P1.5		;store shiftregs to output buffers 
	CLR	P1.5		;the buffers remain unchanged yet

	clr	A		;a small time delay for displaying the line
D1:	DJNZ	ACC,D1
D2:	DJNZ	ACC,D2
;D3:	DJNZ	ACC,D3
;D4:	DJNZ	ACC,D4

	inc	B		;set B back for djnz
	djnz	B,LineLoop	;go to next line shift out (7...1)

	AJMP	DisplayLoop	;again

BITMAP:
	;7 lines/char = 7 bytes (and a 0 byte for easy computing)
	;first byte: pattern for line 0, second byte for line 1 ....
	;the lowest 5 bits in a byte are displayed as a line of char (0 = on)
	;sum 60H characters, the lenght of the table is 8 x 60H = 300H !!
	;subtracted 20H in SerIN routine, chars below 80H substituted with a "?"

	DB	0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,00H	;Space
	DB	0FBH,0FBH,0FBH,0FBH,0FBH,0FFH,0FBH,00H	;!
	DB	0F5H,0F5H,0F5H,0FFH,0FFH,0FFH,0FFH,00H	;"
	DB	0F5H,0F5H,0E0H,0F5H,0E0H,0F5H,0F5H,00H	;#
	DB	0FBH,0F0H,0EBH,0F1H,0FAH,0E1H,0FBH,00H	;$
	DB	0E3H,0EAH,0E5H,0FBH,0F4H,0EAH,0F8H,00H	;%
	DB	0F7H,0EBH,0EBH,0F7H,0EAH,0EDH,0F2H,00H	;&
	DB	0F9H,0F9H,0FDH,0FBH,0FFH,0FFH,0FFH,00H	;'
	DB	0FDH,0FBH,0F7H,0F7H,0F7H,0FBH,0FDH,00H	;(
	DB	0F7H,0FBH,0FDH,0FDH,0FDH,0FBH,0F7H,00H	;)
	DB	0FBH,0EAH,0F1H,0FBH,0F1H,0EAH,0FBH,00H	;*
	DB	0FFH,0FBH,0FBH,0E0H,0FBH,0FBH,0FFH,00H	;+
	DB	0FFH,0FFH,0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0E1H,0EFH,0EFH,00H	;p
	DB	0FFH,0FFH,0F0H,0EEH,0F0H,0FEH,0FEH,00H	;q
	DB	0FFH,0FFH,0E9H,0E6H,0EFH,0EFH,0EFH,00H	;r
	DB	0FFH,0FFH,0F0H,0EFH,0F1H,0FEH,0E1H,00H	;s
	DB	0FBH,0FBH,0F0H,0FBH,0FBH,0FBH,0FCH,00H	;t
	DB	0FFH,0FFH,0EEH,0EEH,0EEH,0ECH,0F2H,00H	;u
	DB	0FFH,0FFH,0EEH,0EEH,0EEH,0F5H,0FBH,00H	;v
	DB	0FFH,0FFH,0EEH,0EEH,0EAH,0EAH,0F4H,00H	;w
	DB	0FFH,0FFH,0EEH,0F5H,0FBH,0F5H,0EEH,00H	;x
	DB	0FFH,0FFH,0EEH,0F5H,0FBH,0FBH,0F3H,00H	;y
	DB	0FFH,0FFH,0E0H,0FDH,0FBH,0F7H,0E0H,00H	;z
	DB	0F9H,0F7H,0F7H,0E7H,0F7H,0F7H,0F9H,00H	;{
	DB	0FBH,0FBH,0FBH,0FFH,0FBH,0FBH,0FBH,00H	;|
	DB	0F3H,0FDH,0FDH,0FCH,0FDH,0FDH,0F3H,00H	;}
	DB	0F5H,0EAH,0FFH,0FFH,0FFH,0FFH,0FFH,00H	;~
	DB	0F5H,0EAH,0F5H,0EAH,0F5H,0EAH,0F5H	;DEL

END


- - - Updated - - -

Even i can give u a proteous project for ur reference....if any1 want it.
 

Attachments

  • 8charDotMatrix.jpg
    8charDotMatrix.jpg
    139.3 KB · Views: 146
Last edited by a moderator:

Re: Need "C" language code from this assembley language for this same circuit diagram

Why don't you contact our friend zuisti? He is an active member of thožis forum.

here i am sending you my (.asm) code for your reference

and first two lines of that .asm:

;Cascadable 8 char dot matrix display

;written by zuisti (shiftregs: 5 x hc595)
 

Re: Need "C" language code from this assembley language for this same circuit diagram

im working on the similar project. i am using 89c2051 with the circuit diagram which zuisti sir has provided. Can zuisti sir pls upload an assembly or c code for led dot matrix using only one module(i.e no DIP switch, only 1 module consisting of 6 char). I am having a very hard time understanding the code. Zuisti sir please help.
 


Re: Need "C" language code from this assembley language for this same circuit diagram

zuisti sir I have a question. I am working on the ELEKTOR PROJECT scrolling message using 6 led 5*7 matrix(i.e. only 1 module). If i use AT89S2051 will there be any change in the hardware and software?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top