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.

8051 timer not working

Status
Not open for further replies.

glk.c.93

Newbie level 1
Newbie level 1
Joined
Sep 1, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
47
Hi,
Iam using ESA51E board, having 80C51BH Ucontroller forn intel.
In my code iam trying to Implement real time clock using timer
When i check for register values in Win51E they wont get updated, while other values does...(like PC, DPTR...etc). im also using 8255
The change of values takes place in ISR, which is not happening. Interrpt is nt getting activated.. what might the problem be?

My code is:

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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
ORG 8100H
 
MOV TCON, #00H
MOV TMOD,#01H ; setting the timer mode to 01
MOV DPTR,#0E803H       ; setting control port to have port A & B as output and port C as input , we take what to display as input
MOV A,#85H
MOVX @DPTR,A
MOV DPTR,#9000H ; initialising time and date    
MOV A,#50    ; sec
MOVX @DPTR,A
INC DPTR
MOV A,#00    ; min
MOVX @DPTR,A
INC DPTR
MOV A,#04      ; hour
MOVX @DPTR,A
INC DPTR
MOV A,#26
MOVX @DPTR,A
INC DPTR
MOV A,#08
MOVX @DPTR,A
INC DPTR
MOV A,#13
MOVX @DPTR,A
SEC_DELAY: MOV R0,#167 ; one second delay routine
REPEAT:
CLR TF0
MOV TL0,#60H
MOV TH0,#0EAH
SETB TR0
TIMER_LOOP:
JNB TF0,DISPLAY ; repeat SEC_DELAY if timer flag is set
CLR TF0
CLR TR0
DJNZ R0,REPEAT
ACALL UPDATE
SJMP SEC_DELAY    
 
UPDATE:
MOV DPTR,#9000H ; update second
MOVX A,@DPTR
INC A
CJNE A,#60,SAVE_TIME
MOV A,#00H
MOVX @DPTR,A
 
INC DPTR          ; update minute
MOVX A,@DPTR
INC A
CJNE A,#60,SAVE_TIME
MOV A,#00H
MOVX @DPTR,A
 
INC DPTR           ; update hour
MOVX A,@DPTR
INC A
CJNE A,#24,SAVE_TIME
MOV A,#00H
MOVX @DPTR,A
 
INC DPTR           ; update date
MOVX A,@DPTR       ; read Date
INC A
MOV R2, A
INC DPTR
MOVX A, @DPTR      ; reading month
MOV DPTR, #84FFH
MOVC A, @A+DPTR    ; reading valid days in a month
INC A
MOV DPTR, #9003H
MOV 3, 2
MOV 2, A
MOV A, 3
CJNE A, 2, SAVE_TIME
MOV A,#01H
MOVX @DPTR,A
INC DPTR ; update month
MOVX A,@DPTR
INC A
CJNE A,#13,SAVE_TIME
MOV A,#01H
MOVX @DPTR,A
INC DPTR ; update year
MOVX A,@DPTR
INC A
MOVX @DPTR,A
RET
SAVE_TIME:
MOVX @DPTR,A ; routine to save time and date parameters in the external memory
RET
DISPLAY:
MOV DPTR,#0E802H      ; complete display routine
MOVX A,@DPTR
JB ACC.3,DATE_DISP    ; pin 3 of port C used as mode pin, high=>display date, low=>display    time
TIME_UPDATE:
MOV DPTR,#9000H          ; second
MOVX A,@DPTR
MOV B, #0AH
DIV AB                   ; dividing to get units and tens digits of second
MOV R1,A
ACALL NUMBER_DISPLAY     ; call the routine to display a number
MOV A,#00111110B         ; units place 7-segment display is on, rest are off
MOV DPTR,#0E801H
MOVX @DPTR,A
ACALL SMALL_DELAY        ; small delay
MOV A,#0FFH              ; to turn off all 7-segment displays
MOVX @DPTR,A             
MOV B,R1
ACALL NUMBER_DISPLAY
MOV A,#00111101B         ; tens place 7-segment display and so on further
MOV DPTR,#0E801H
MOVX @DPTR,A
ACALL SMALL_DELAY
MOV A,#0FFH
MOVX @DPTR,A
MOV DPTR,#9001H         ; minutes
MOVX A,@DPTR
MOV B, #0AH
DIV AB
MOV R1,A
ACALL NUMBER_DISPLAY
MOV A,#00111011B
MOV DPTR,#0E801H
MOVX @DPTR,A
ACALL SMALL_DELAY
MOV A,#0FFH
MOVX @DPTR,A
MOV B,R1
ACALL NUMBER_DISPLAY
MOV A,#00110111B
MOV DPTR,#0E801H
MOVX @DPTR,A
ACALL SMALL_DELAY
MOV A,#0FFH
MOVX @DPTR,A
MOV DPTR,#9002H           ; hours
MOVX A,@DPTR
MOV B, #0AH
DIV AB
MOV R1,A
ACALL NUMBER_DISPLAY
MOV A,#00101111B
MOV DPTR,#0E801H
MOVX @DPTR,A
ACALL SMALL_DELAY
MOV A,#0FFH
MOVX @DPTR,A
MOV B,R1
ACALL NUMBER_DISPLAY
MOV A,#00011111B
MOV DPTR,#0E801H
MOVX @DPTR,A
ACALL SMALL_DELAY
MOV A,#0FFH
MOVX @DPTR,A
LJMP TIMER_LOOP
 
DATE_DISP:
MOV DPTR,#9005H ; year
MOVX A,@DPTR
MOV B, #0AH
DIV AB
MOV R1,A
ACALL NUMBER_DISPLAY
MOV A,#00111110B
MOV DPTR,#0E801H
MOVX @DPTR,A
ACALL SMALL_DELAY
MOV A,#0FFH
MOVX @DPTR,A
MOV B,R1
ACALL NUMBER_DISPLAY
MOV A,#00111101B
MOV DPTR,#0E801H
MOVX @DPTR,A
ACALL SMALL_DELAY
MOV A,#0FFH
MOVX @DPTR,A
MOV DPTR,#9004H ; month
MOVX A,@DPTR
MOV B, #0AH
DIV AB
MOV R1,A
ACALL NUMBER_DISPLAY
MOV A,#00111011B
MOV DPTR,#0E801H
MOVX @DPTR,A
ACALL SMALL_DELAY
MOV A,#0FFH
MOVX @DPTR,A
MOV B,R1
ACALL NUMBER_DISPLAY
MOV A,#00110111B
MOV DPTR,#0E801H
MOVX @DPTR,A
ACALL SMALL_DELAY
MOV A,#0FFH
MOVX @DPTR,A
MOV DPTR,#9003H ; date
MOVX A,@DPTR
MOV B, #0AH
DIV AB
MOV R1,A
ACALL NUMBER_DISPLAY
MOV A,#00101111B
MOV DPTR,#0E801H
MOVX @DPTR,A
ACALL SMALL_DELAY
MOV A,#0FFH
MOVX @DPTR,A
MOV B,R1
ACALL NUMBER_DISPLAY
MOV A,#00011111B
MOV DPTR,#0E801H
MOVX @DPTR,A
ACALL SMALL_DELAY
MOV A,#0FFH
MOVX @DPTR,A
LJMP TIMER_LOOP
 
NUMBER_DISPLAY:
MOV A,#00H ; display zero
CJNE A,B,L1
MOV DPTR,#0E800H
MOV A,#3FH
MOVX @DPTR,A
SJMP EXIT_NUMBER_DISPLAY
 
L1:     
        MOV A,#01H ; display one
CJNE A,B,L2
MOV DPTR,#0E800H
MOV A,#00000110B
MOVX @DPTR,A
SJMP EXIT_NUMBER_DISPLAY
L2:
MOV A,#02H ; display two
CJNE A,B,L3
MOV DPTR,#0E800H
MOV A,#5BH
MOVX @DPTR,A
SJMP EXIT_NUMBER_DISPLAY
L3:
MOV A,#03H ; display three
CJNE A,B,L4
MOV DPTR,#0E800H
MOV A,#4FH
MOVX @DPTR,A
SJMP EXIT_NUMBER_DISPLAY
L4:
MOV A,#04H ; display four
CJNE A,B,L5
MOV DPTR,#0E800H
MOV A,#66H
MOVX @DPTR,A
SJMP EXIT_NUMBER_DISPLAY
L5:
MOV A,#05H ; display five
CJNE A,B,L6
MOV DPTR,#0E800H
MOV A,#6DH
MOVX @DPTR,A
SJMP EXIT_NUMBER_DISPLAY
L6:
MOV A,#06H ; display six
CJNE A,B,L7
MOV DPTR,#0E800H
MOV A,#7DH
MOVX @DPTR,A
SJMP EXIT_NUMBER_DISPLAY
L7:
MOV A,#07H ; display seven
CJNE A,B,L8
MOV DPTR,#0E800H
MOV A,#07H
MOVX @DPTR,A
SJMP EXIT_NUMBER_DISPLAY
L8:
MOV A,#08H ; display eight
CJNE A,B,L9
MOV DPTR,#0E800H
MOV A,#7FH
MOVX @DPTR,A
SJMP EXIT_NUMBER_DISPLAY
L9:
MOV DPTR,#0E800H ; display nine
MOV A,#6FH
MOVX @DPTR,A
EXIT_NUMBER_DISPLAY:
RET
SMALL_DELAY :
MOV R3,#10
DELAY_AGAIN:
DJNZ R3,DELAY_AGAIN
RET
END

 
Last edited by a moderator:

i have n't worked with assembly language but
you check if you have configured the ISR enabled ? If no, enable.
If yes , check the ISR priority level if it conflicts with any other?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top