t89c51ac2 interrupt

Discussion in 'Programmer's Corner' started by djstar, Dec 10, 2010.

  1. djstar

    Thread Starter Active Member

    Jan 26, 2008
    37
    0
    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

    Code ( (Unknown Language)):
    1.  
    2.  
    3.   main1()
    4.  
    5. {
    6.  
    7. #pragma asm
    8.                 mov IE, #81h                ;// enbales interupts and enable external 0 interupt//
    9.  
    10. interupt:  
    11.                 ORG 0003H                   ;// vector address //
    12.                
    13.                 mov P3, #0bfh               ;// turn on led 3.6//
    14.                
    15.                 RETI                        ;// return to program //
    16.  
    17.  
    18.    
    19.    
    20.                
    21.                
    22.                
    23.                 ORG 0030H                   ;// return to main program //
    24.                
    25. start:             
    26.                 mov P3, #0dfh               ;// Turn on led  p3.5//
    27.                
    28.                 acall, delay                        ;//  delay //
    29.                
    30.                 mov P3, #7fh                ;// turn on led p3.7 //
    31.                
    32.                 acall, delay                        ;//  delay //
    33.                
    34.                 SJMP, start                 ;//  jump to start //
    35.                
    36.  
    37. delay:
    38.  
    39.    
    40.                 mov r7,#0fh                 ;// move 0fh to reg 7//
    41. outerloop1:        
    42.                
    43.  
    44.                 mov r6, #0ffh               ;// move ffh to reg 6//
    45. innerloop1:
    46.  
    47.  
    48.                 mov r5, #0ffh               ;// move ffh to reg 5//
    49. inner:     
    50.  
    51.                 djnz r5 inner
    52.                
    53.                 djnz r6 innerloop1
    54.                
    55.                 djnz r7 outerloop1
    56.                
    57.                
    58.                
    59.  
    60. #pragma endasm
    61.  
    62. }                          
    63.  
    64.  
    65.                          
    66.  
    67.  
     
Loading...