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.

Why This Program didn't go to Timer Interrupt routine?(ASM 8051)

Status
Not open for further replies.

panda1234

Full Member level 2
Joined
Jan 22, 2015
Messages
125
Helped
4
Reputation
8
Reaction score
4
Trophy points
18
Activity points
1,172
Hi,
PHP:
		 ORG 00H
		 SJMP MAIN
		 ORG 03H
		 acall isr
		 MOV P2,#11111000B
		 RETI
		ORG 0BH
			LJMP T0ISR
		 ORG 60H                
MAIN:            
         MOV IE,#81H
		 MOV P2,#11111000B
		 
	 /*	 TWO DIGITS ARE STORED IN R7,R6 RESPECTIVELY .PLEASE ENTER YOUR CODE FOR FREQUENCY GENERATION HERE
		  */
           MOV TMOD,#02H
		   MOV TH0,#-50
		   SETB TR0
		   SETB EA
		   SJMP $



                    
                  

            

			SJMP MAIN
                        

              
			  
isr:	  

                 ACALL SCAN
                 MOV R7,A
                 ACALL SCAN
                 MOV R6,A
				 MOV B,R7
				 MOV A,#10
				 MUL AB
				 ADD A,R6
				 MOV R7,A      //R7 0.1 Frequency
				 ACALL SCAN
                 ACALL SCAN
                 MOV R5,A
				 ACALL SCAN
                 MOV R4,A
				 MOV B,R5
				 MOV A,#10
				 MUL AB
				 ADD A,R4
				 MOV R6,A
                 ACALL SCAN
				MOV R5,#1    //Start
                LJMP MAIN
		  JNB P2.3,$
		  JNB P2.4,$
		  JNB P2.5,$
		  JNB P2.5,$	
              	
			
		  RET
		  
		  T0ISR:
		  CPL P1.0
		  RETI
		  RETI



SCAN:
          MOV A,#11111111B                
          MOV P2,A    
          CLR P2.0        
          JB P2.3,J1
		  JNB P2.3,$   ;KEY DEBOUNCE, DELETE THIS LINE TO CHECK THE EFFECT
          MOV A,#3
          RET
   J1:
          JB P2.4,J2
		  JNB P2.4,$
          MOV A,#6
          RET
   J2:
          JB P2.5,J3
		  JNB P2.5,$	 ;
          MOV A,#9
          RET
   J3:
          JB P2.6,J4
		  JNB P2.6,$
          MOV A,#10
          RET
   J4:
          SETB P2.0
          CLR P2.1
          JB P2.3,J5
		  JNB P2.3,$
          MOV A,#2
          RET
   J5:
          JB P2.4,J6
		  JNB P2.4,$
          MOV A,#5
          RET
   J6:
          JB P2.5,J7
		  JNB P2.5,$
          MOV A,#8
          RET
   J7:
          JB P2.6,J8
		  JNB P2.6,$
          MOV A,#0
          RET
   J8:
          SETB P2.1
          CLR P2.2
          JB P2.3,K1
		  JNB P2.3,$
          MOV A,#1
          RET
   K1:
          JB P2.4,K2
		  JNB P2.4,$
          MOV A,#4
          RET
   K2:
          JB P2.5,K3
		  JNB P2.5,$
          MOV A,#7
          RET
   K3:
          JB P2.6,K4
		  JNB P2.6,$
          MOV A,#11
          RET
   K4:	  AJMP SCAN


          END
 

It looks like your code has 2 interrupt routines. One for Int0 at interrupt vector 03H and one for Timer 0 at interrupt vector 0BH. I see that in main you enable global interrupts, but I don't see interrupts enabled for timer 0 or external interrupt 0 (SETB ET0 or SETB EX0). Also, you may need to clear the interrupt flags in your service routines.
 

but I don't see interrupts enabled for timer 0 or external interrupt 0 (SETB ET0 or SETB EX0)
External interrupt is enabled by writing 0x81 to IE register, but timer interrupt isn't.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top