[SOLVED] Very strange problem

Status
Not open for further replies.

nusyil

Newbie
Joined
May 6, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,312
Hi all !!

When i try to write to 16x2 44780 based LCD, i've encountered very strange problem. When i try to write to LCD " FM 89.1 Mhz" there is no problem, works perfectly.

But, if i try to write " FM 89.0 Mhz" there is nothing on the screen !! zero after dot doesn't work!! however 1,2 etc,after dot works.

My controller is AT89C52. I tried all in ISIS, not real life. My codes are below.

Any suggestions?

Thanks in advance.



Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
$mod51
$nosymbols
org 0000h
ljmp mainprogram
org 0100h       
mainprogram:    
 
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
; example: Delay 50                              provides 50 msn delay  
delay    macro carpan                   
 
local den
                
                        mov             r3,#carpan
den:            Mov             tmod,#1
                        mov             tl0,#66h        ;lower byte
                        mov             th0,#0fch       ;upper byte
                        setb    tr0                                             
                        jnb             tf0,$
                        clr             tf0
                        djnz    r3,den
                        endm                                    
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;========================================================================
;                       definitions
;========================================================================
rs                      bit p1.0
rw                      bit p1.1
en                      bit p1.2
 
command         equ     52h
port            equ     p0      ;       lcd port lines connected to p0
;=======================================================================
;                       initialization
;=======================================================================
mov     p0,#0
mov     p1,#0
;=======================================================================
;                       main program
;=======================================================================
mensage:        Db 'fm  89.0Mhz',99h
                        
                        lcall init_lcd
                        mov     dptr,#mensage
don:            Mov     a,#0
                        movc a,@a+dptr
                        cjne a,#99h,continue
                        jmp $
continue:       Lcall   write_text
                        inc     dptr
                        jmp     don
 
;========================================================================
init_lcd:
                Clr   rs
                clr   rw
                clr   en
                setb  en
                mov   port,#28h
                clr   en
                delay 1
                
                mov   a,#28h                    ;       function set
                lcall write_2_nibbles
                delay   1
                        
                mov   a,#0eh                    ;       display on-off kontrol
                lcall write_2_nibbles
                delay 1
                
                mov   a,#06h                    ;       entry mode set
                lcall write_2_nibbles
                delay 1
                
                mov   a,#80h                    ;       ddram adres select
                lcall write_2_nibbles
                delay 1
        
                ret
 
;========================================================================
 
write_2_nibbles:                                ;       write a as two separate nibbles to lcd
                mov             command,a                       
                orl             a,#0fh
                mov             port,a
                setb    en
                clr             en
                
                mov             a,command
                orl             a,#0f0h
                swap    a
                mov             port,a
                setb    en
                clr             en
                ret
;========================================================================
             
 clear_lcd:
                Clr   rs                                
                mov   a,#01h
                lcall write_2_nibbles   
                delay 5
                ret
;========================================================================
 
write_text:
                Setb  rs                                
                lcall write_2_nibbles
                delay 5
                ret
;========================================================================
 
 end

 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…