t89c51ac2 interrupt

Thread Starter

djstar

Joined Jan 26, 2008
39
Hi i am very new to assembly langauge and im studying it at college, ive only had 5 1 hour lessons so im just gettting my head around how every thing works. we have a robot called robo51 that uses the t89c51ac2. i have ben asked to to connect a external switch to the robot and use this to operate a interrupt. The robot has ports p3.5, p3.6 and p3.7 conected to a led and a 10k pull up resistor. what we have been told to do is to make the leds on ports 3.5 and 3.7 alterntavely flash on and off and when the button is pressed it jumps to the intterupt and led p3.6 stays on permantly then when the button is relesed the lights start to flash on and of again and the led p3.6 turns off. i do apologise if my coding is poor or amateurist but like i said i am very new to this.

from the label "Delay:" and below, i undertsand and this will make the leds flash alternatively, however, i had a go at programing the interupt part but im not sure what is going on or if i have type the right code. Any help would truely be appreciated. if you need any more information then please dont hestitat to ask.

laura

Rich (BB code):
  main1()

{

#pragma asm
				mov IE, #81h				;// enbales interupts and enable external 0 interupt//

interupt:	
				ORG 0003H					;// vector address //
				
				mov P3, #0bfh				;// turn on led 3.6//
			 	
				RETI						;// return to program //


    
	
				
				
				
				ORG 0030H					;// return to main program //
				
start:				
				mov P3, #0dfh 				;// Turn on led  p3.5//
				
				acall, delay				        ;//  delay //
				
				mov P3, #7fh 				;// turn on led p3.7 //
				
				acall, delay				        ;//  delay //
				
				SJMP, start					;//  jump to start //
				

delay:

	
				mov r7,#0fh 				;// move 0fh to reg 7//
outerloop1:			
				

				mov r6, #0ffh				;// move ffh to reg 6//
innerloop1:	


				mov r5, #0ffh				;// move ffh to reg 5//
inner:		

				djnz r5 inner
				
				djnz r6 innerloop1
				
				djnz r7 outerloop1
				
				
				

#pragma endasm

}
 
Top