Home - Search - Members
Full Version: need timer interrupt using assembly language.
Pages: 1, 2
SAMEET
Aug 29 2009, 10:48 AM
i require code for 5 sec delay using timer interrupt 0 in 16-bit mode in assembly language for 89s51.

Ajay Bhargav
Aug 30 2009, 6:44 AM
well i explained many times..

create 50ms timer and then use a counter to count 100. coz 100*50 = 5000ms = 5sec

SAMEET
Aug 30 2009, 11:14 AM
my friend i wannna do it using timer interrupt and hope u give me program for that.


Ajay Bhargav
Aug 30 2009, 3:42 PM
Well i cant give your a program, but you can do that in interrupt.. just add the counter logic in interrupt routine.

write something yourself, i will rectify it incase of any errors. unless you try you wont learn.
gopi
Aug 31 2009, 3:33 AM
Let me explain you the steps to perform Timer interrupt0:-
----------------------------------------------------------------------
1. Enter "IE" reg. value to initialize the timer0 interrupt.
2. Enter the "TMOD" reg. value to select the timer0 with 16-bit mode.
3.Enter the values at "TH0 & TL0" as per the time delay you requested.
ex:-If 12MHz XTAL connected means, the constant time delay taken between each count is 1┬Ásec. Else if 24MHz XTAL means, then 0.5┬Ásec is the constant time delay.
4. Start the timer0.
5. Write the ISR program under the pre-defined Timer interrupt 0 address.
SAMEET
Aug 31 2009, 7:33 AM
MR GOPI AND AJAY

I AM SENDING U MY PROGRAM USING ADC 0804 HERE I AM DISPLAYING 336V WITH THREE 7 SEGMENT DISPLAY.

SO WHEN I MAKE MY MACHINE ON DURING CAPACITOR TAKES 3 SECONDS TO CHARGE UPTO 336V
SO I NEED TO PUT DELAY FOR 5 SEC TO ALLOW NOT TO GET OL ERROR AROUND 220V TO 200V WHEN I PROVIDE SUPPLY. FOR FIRST TIME U WILL BE ABLE TO GET IT AND I WANNA USE TIMER INTERRUPT TO CHECK OL VOLTAGE AFTER EVERY 5 SEC. I AM ATTACHING MY PROGRAM WITH THE HELP OF TIMER VERIFY WHETHER I AM CORRECT.
gopi
Sep 1 2009, 12:34 AM
I didnt see any attachment here???????????????
SAMEET
Sep 1 2009, 11:59 AM
hiiiiiiiii this is program
gopi
Sep 2 2009, 3:50 AM
Where is it????????
gopi
Sep 2 2009, 4:04 AM
Ok Buddy. I am sending one reference code where a set of leds connected to PORT1 has to be blinked for every 1sec using timer0 interrupt with 16-bit mode. The XTAL used is 11.0592.

                     temp data 40h
                     cnt    data 00h

                      org 00h
                      ljmp main

                      org 0bh
                      clr tr0
                      djnz cnt,down
                      mov cnt,#14
                      mov a,temp
                      cpl a
                      mov temp,a
                      mov P1,temp
                      mov th0,#0
                      mov tl0,#0
down:            setb tr0
                      reti

main:             mov cnt,#14
                     mov temp,#55h
                      mov tmod,#01h
                      mov th0,#0
                      mov tl0,#0
                      mov ie,#82h
                      setb tr0
                      sjmp $
SAMEET
Sep 4 2009, 2:55 AM
THANKS FOR GIVING ME THIS CODE BUT I HAVE TO INCORPORATE WITH MY ADC 0804 PROGRAM WHICH I GAVE U EARLIER AGAIN I WILL SEND.
THIS IS USING TABLE TO DISPLAY 0-336 VDC JUS GO THRU IF U FIND EASY TO UNDERSTAND
;****************************************************************************
;
; Experiment # exp11 -> Matrix Display program 1
;
;****************************************************************************
;RAM_ADDR EQU 40H




ORG 0000H ;Starting address
AJMP MAIN
ORG 000BH
AJMP LIMIT
; ----------------------------------------; MOV SP,#60H ;Initialize stack pointer.
ORG 0100H
MAIN: MOV R7,#00H ;Initialize display digit.
MOV 50H,#00H
MOV 51H,#00H
MOV 52H,#00H
MOV 53H,#00H
MOV 54H,#00H
MOV 55H,#92H
MOV 56H,#82H
MOV 57H,#0F8H
;-----------------------------------------------;
;KEY_UP: ;
; JB P2.0,KEY_UP ;Detect a key closer
;Detect a key release
;-----------------------------------------------;

;******************************************************************************
; ADC DATA TO MICROCONTROLLER
;*******************************************************************************
MOV P2,#00H
MOV P1,#0FFH
MOV P3,#04H
MOV P0,#00H

;ACALL DELAY
MOV TMOD,#01H
MOV TH0,#01H
MOV TL0,#00H

MOV IE,#82H

H1: SETB P3.7 ;READ DATA

;H1: JB P3.7,H1


;*******************************************************************************
; BINARY TO DECIMAL
;*********************************************************************************




;MOV R0,#RAM_ADDR ;SAVE DEC DIGITS IN THESE RAM LOCATIONS
;CJNE A,#77H,OVER

MOV A,P1 ;READ DAT FROM P2
SETB TR0
ACALL LINEAR

MOV A,40H
ACALL CONVERT
MOV P0,A
MOV P2,#03H
ACALL DELAY

MOV A,41H
ACALL CONVERT
MOV P0,A
MOV P2,#02H
ACALL DELAY

MOV A,42H
ACALL CONVERT
MOV P0,A
MOV P2,#01H
ACALL DELAY
SJMP H1

LIMIT: MOV R5,P1
CJNE R5,#2CH,L1
SJMP BACK
L1: CJNE R5,#2DH,L2
SJMP BACK
L2: CJNE R5,#2EH,L3
SJMP BACK
L3: CJNE R5,#2FH,L4
SJMP BACK
L4: CJNE R5,#30H,L5
SJMP BACK
L5: CJNE R5,#31H,L6
SJMP BACK
L6: CJNE R5,#32H,L7
SJMP BACK
L7: CJNE R5,#33H,L8
SJMP BACK
BACK: NOP
MOV P0,#3FH
MOV P2,#02H
ACALL DELAY
MOV P0,#38H
MOV P2,#03H
ACALL DELAY
SJMP BACK
L8: RETI
DELAY: MOV R2,#10
LOOP2: MOV R6,#10
LOOP1: MOV R5,#10
LOOP3: DJNZ R5,LOOP3
DJNZ R6,LOOP1
DJNZ R2,LOOP2
RET

LINEAR: CJNE A,#00H,G1
MOV 40H,#00
MOV 41H,#00
MOV 42H,#00
LJMP DONE
G1: CJNE A,#01H,G2
MOV 40H,#01
MOV 41H,#00
MOV 42H,#00
LJMP DONE
G2: CJNE A,#02H,G3
MOV 40H,#02
MOV 41H,#00
MOV 42H,#00
LJMP DONE
G3: CJNE A,#03H,G4
MOV 40H,#03
MOV 41H,#00
MOV 42H,#00
LJMP DONE
G4: CJNE A,#04H,G5
MOV 40H,#05
MOV 41H,#00
MOV 42H,#00
LJMP DONE
G5: CJNE A,#05H,G6
MOV 40H,#06
MOV 41H,#00
MOV 42H,#00
LJMP DONE
G6: CJNE A,#06H,G7
MOV 40H,#07
MOV 41H,#00
MOV 42H,#00
LJMP DONE
G7: CJNE A,#07H,G8
MOV 40H,#08
MOV 41H,#00
MOV 42H,#00
LJMP DONE
G8: CJNE A,#08H,G9
MOV 40H,#00
MOV 41H,#01
MOV 42H,#00
LJMP DONE
G9: CJNE A,#09H,G10
MOV 40H,#01
MOV 41H,#01
MOV 42H,#00
LJMP DONE
G10: CJNE A,#0AH,G11
MOV 40H,#02
MOV 41H,#01
MOV 42H,#00
LJMP DONE
G11: CJNE A,#0BH,G12
MOV 40H,#03
MOV 41H,#01
MOV 42H,#00
LJMP DONE
G12: CJNE A,#0CH,G13
MOV 40H,#05
MOV 41H,#01
MOV 42H,#00
LJMP DONE
G13: CJNE A,#0DH,G14
MOV 40H,#06
MOV 41H,#01
MOV 42H,#00
LJMP DONE
G14: CJNE A,#0EH,G15
MOV 40H,#07
MOV 41H,#01
MOV 42H,#00
LJMP DONE
G15: CJNE A,#0FH,G16
MOV 40H,#08
MOV 41H,#01
MOV 42H,#00
LJMP DONE
G16: CJNE A,#10H,G17
MOV 40H,#00
MOV 41H,#02
MOV 42H,#00
LJMP DONE
G17: CJNE A,#11H,G18
MOV 40H,#01
MOV 41H,#02
MOV 42H,#00
LJMP DONE
G18: CJNE A,#12H,G19
MOV 40H,#02
MOV 41H,#02
MOV 42H,#00
LJMP DONE
G19: CJNE A,#13H,G20
MOV 40H,#03
MOV 41H,#02
MOV 42H,#00
LJMP DONE
G20: CJNE A,#14H,G21
MOV 40H,#05
MOV 41H,#02
MOV 42H,#00
LJMP DONE
G21: CJNE A,#15H,G22
MOV 40H,#06
MOV 41H,#02
MOV 42H,#00
LJMP DONE
G22: CJNE A,#16H,G23
MOV 40H,#07
MOV 41H,#02
MOV 42H,#00
LJMP DONE
G23: CJNE A,#17H,G24
MOV 40H,#08
MOV 41H,#02
MOV 42H,#00
LJMP DONE
G24: CJNE A,#18H,G25
MOV 40H,#00
MOV 41H,#03
MOV 42H,#00
LJMP DONE
G25: CJNE A,#19H,G26
MOV 40H,#01
MOV 41H,#03
MOV 42H,#00
LJMP DONE
G26: CJNE A,#1AH,G27
MOV 40H,#02
MOV 41H,#03
MOV 42H,#00
LJMP DONE
G27: CJNE A,#1BH,G28
MOV 40H,#03
MOV 41H,#03
MOV 42H,#00
LJMP DONE
G28: CJNE A,#1CH,G29
MOV 40H,#05
MOV 41H,#03
MOV 42H,#00
LJMP DONE
G29: CJNE A,#1DH,G30
MOV 40H,#06
MOV 41H,#03
MOV 42H,#00
LJMP DONE
G30: CJNE A,#1EH,G31
MOV 40H,#07
MOV 41H,#03
MOV 42H,#00
LJMP DONE
G31: CJNE A,#1FH,G32
MOV 40H,#09
MOV 41H,#03
MOV 42H,#00
LJMP DONE
G32: CJNE A,#20H,G33
MOV 40H,#00
MOV 41H,#04
MOV 42H,#00
LJMP DONE
G33: CJNE A,#21H,G34
MOV 40H,#01
MOV 41H,#04
MOV 42H,#00
LJMP DONE
G34: CJNE A,#22H,G35
MOV 40H,#02
MOV 41H,#04
MOV 42H,#00
LJMP DONE
G35: CJNE A,#23H,G36
MOV 40H,#03
MOV 41H,#04
MOV 42H,#00
LJMP DONE
G36: CJNE A,#24H,G37
MOV 40H,#05
MOV 41H,#04
MOV 42H,#00
LJMP DONE
G37: CJNE A,#25H,G38
MOV 40H,#06
MOV 41H,#04
MOV 42H,#00
LJMP DONE
G38: CJNE A,#26H,G39
MOV 40H,#07
MOV 41H,#04
MOV 42H,#00
LJMP DONE
G39: CJNE A,#27H,G40
MOV 40H,#08
MOV 41H,#04
MOV 42H,#00
LJMP DONE
G40: CJNE A,#28H,G41
MOV 40H,#09
MOV 41H,#04
MOV 42H,#00
LJMP DONE
G41: CJNE A,#29H,G42
MOV 40H,#01
MOV 41H,#05
MOV 42H,#00
LJMP DONE
G42: CJNE A,#2AH,G43
MOV 40H,#02
MOV 41H,#05
MOV 42H,#00
LJMP DONE
G43: CJNE A,#2BH,G44
MOV 40H,#03
MOV 41H,#05
MOV 42H,#00
LJMP DONE
G44: CJNE A,#2CH,G45
MOV 40H,#05
MOV 41H,#05
MOV 42H,#00
LJMP DONE
G45: CJNE A,#2DH,G46
MOV 40H,#06
MOV 41H,#05
MOV 42H,#00
LJMP DONE
G46: CJNE A,#2EH,G47
MOV 40H,#07
MOV 41H,#05
MOV 42H,#00
LJMP DONE
G47: CJNE A,#2FH,G48
MOV 40H,#09
MOV 41H,#05
MOV 42H,#00
LJMP DONE
G48: CJNE A,#30H,G49
MOV 40H,#01
MOV 41H,#06
MOV 42H,#00
LJMP DONE
G49: CJNE A,#31H,G50
MOV 40H,#02
MOV 41H,#06
MOV 42H,#00
LJMP DONE
G50: CJNE A,#32H,G51
MOV 40H,#05
MOV 41H,#06
MOV 42H,#00
LJMP DONE
G51: CJNE A,#33H,G52
MOV 40H,#08
MOV 41H,#06
MOV 42H,#00
LJMP DONE
G52: CJNE A,#34H,G53
MOV 40H,#09
MOV 41H,#06
MOV 42H,#00
LJMP DONE
G53: CJNE A,#35H,G54
MOV 40H,#00
MOV 41H,#07
MOV 42H,#00
LJMP DONE
G54: CJNE A,#36H,G55
MOV 40H,#01
MOV 41H,#07
MOV 42H,#00
LJMP DONE
G55: CJNE A,#37H,G56
MOV 40H,#03
MOV 41H,#07
MOV 42H,#00
LJMP DONE
G56: CJNE A,#38H,G57
MOV 40H,#04
MOV 41H,#07
MOV 42H,#00
LJMP DONE
G57: CJNE A,#39H,G58
MOV 40H,#05
MOV 41H,#07
MOV 42H,#00
LJMP DONE
G58: CJNE A,#3AH,G59
MOV 40H,#06
MOV 41H,#07
MOV 42H,#00
LJMP DONE
G59: CJNE A,#3BH,G60
MOV 40H,#08
MOV 41H,#07
MOV 42H,#00
LJMP DONE
G60: CJNE A,#0FFH,G61
MOV 40H,#06
MOV 41H,#03
MOV 42H,#03
LJMP DONE
;-----------------------------------------------------------------
;----------150=96=3.0V-------------------------------------------------------------

G61: CLR C
DONE: RET












;DELAY1: MOV R2,#100
;LOOP21: MOV R6,#100
;LOOP11: MOV R5,#100
;LOOP31: DJNZ R5,LOOP31
; DJNZ R6,LOOP11
; DJNZ R2,LOOP21
; RET



;****************************************************************************
CONVERT: ;
INC A ;
MOVC A,@A+PC ;
RET ;
DB 3FH ;0-1
DB 06H ;1-2
DB 5BH ;2- 3
DB 4FH ;3-4
DB 66H ;4-5
DB 6DH ;5-6
DB 7DH ;6-7
DB 07H ;7-8
DB 7FH ;8-9
DB 6FH ;9-10
DB 3FH ;0-11
DB 06H ;1-12
DB 5BH ;2-13
DB 4FH ;3-14
DB 66H ;4-15
DB 6DH ;5-16
DB 7DH ;6-17
DB 07H ;7-18
DB 7FH ;8-19
DB 6FH ;9-20
; ----------------------------------------;
END ;
;***************************************************************************
;DB 3FH ;0
;DB 06H ;1
;DB 5BH ;2
;DB 4FH ;3
;DB 66H ;4
;DB 6DH ;5
; DB 7DH ;6
;DB 07H ;7
;DB 7FH ;8
;DB 6FH ;9
;DB 77H;
;DB 7CH;
;DB 39H;
;DB 5EH;
;DB 79H;
;DB 71H;
Ajay Bhargav
Sep 5 2009, 3:22 AM
SAMEET, if you can put this thing in a zip and proper organized way i may add this to projects section. If you are interested then just mail the things at
contact [at] rickeyworld [dot] info
SAMEET
Sep 8 2009, 7:11 AM
hiiiiiii i wanna attach it but i dont know how to send in zip format
Ajay Bhargav
Sep 9 2009, 2:22 AM
never mind.. your code is hard to understand. its better to put comments too.

to attach file, click on "preview" button or "post reply" button. You will get option to attach file.
SAMEET
Sep 9 2009, 3:19 AM
its easiest way i have written not a problem okkkk fine
SAMEET
Sep 10 2009, 6:09 AM
NOW I WANT TO MULTIPLY 00 TO FF WITH 1.32 AND TO DISPLAY IN DECIMAL VALUE. HOPE I GET A REPLY SOON
SAMEET
Sep 14 2009, 1:58 AM
hiiiiiii can anybody help me for displaying 0-336vdc for 0-FFH steps(i.e 0-255) on three 7 segment display
Ajay Bhargav
Sep 14 2009, 4:38 PM
for 0xff you have 336v. so each step will become 336/0xff or 336/255 = 1.32 approx

just multiply whatever digital value u got, multiply it with 1.32, you will get voltage.

to display, separate each digit and display.

say you got 99v to display. lets get digit 1
it will be, 99/100 = 0
renove first digit now, 99%100 = 99
second digit:
99/10 = 9
remove second digit:
99%10=9

now display them 1 by 1
SAMEET
Sep 14 2009, 11:04 PM
HIIIIIIIIIII I AM ATTACHING HERE MY PROGRAM WHICH IS DISPLAYIN 0-255 FOR 0-FFH BUT AS U TOLD ME TO MULTIPLY WITH 1.32 WHICH I ALREADY THOUGHT BUT HOW TO MULTIPLY IT WITH THAT IS MY PROBLEM IN THIS PROGRAM

Attachment
Ajay Bhargav
Sep 17 2009, 7:56 AM
use math library available in download section..

so first multiply with 132 and the divide by 100, if you want 1 decimal point the divide by 10.
SAMEET
Sep 18 2009, 1:26 AM
i am attaching u my program can u guide me how i multiply 3 digit no 132. so kindly look into this
Attachment
Ajay Bhargav
Sep 19 2009, 7:22 AM
well 132 is a 8-bit number and ADC values is also 8-bit so just multiply both using MUL AB instruction in 8051.

put ADC value in A
132 in B

AxB = BA => B(MSB), A(LSB)

a 16-bit value.. you can easily manipulate the result for display.
SAMEET
Sep 20 2009, 6:56 AM
THANK YOU FOR UR HELP BUT NOW I AM FINDING DIFFICULTY IN DIVIDING 16 BIT BY 8 BIT HOPE U GIVE ME A EXPLANATION. COZ AS U DO IT USING SUBTRACTION I GONE THRU UR PROGRAM BUT HOPE U GIVE ME EXAMPLE OF ATLEAST ONE CYCLE MEANS IF I WANNA CONVERT FFH TO 336V.
THANK YOU.
Ajay Bhargav
Sep 22 2009, 4:49 PM
i think you can find 16 bit division in code section..

check this link:
http://www.8051projects.net/downloads35.html
SAMEET
Oct 1 2009, 4:48 AM
I want timer interrupt program of 5 sec in assembly language help me
Arun Kumar V
Oct 1 2009, 10:34 AM

what value xtal are you using ? direct 5 sec delay is not possible, you'd have to first do a delay for 50millisec and then a counter for 100 times , 50 millisec X 100 times = 5000 msec or 5 seconds.


Arun
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Rickey's World © 2003 - 2007