Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/12/10 22:59
Read: times


 
#180107 - Just for startup to 8051 mcu
Responding to: ???'s previous message
Since you studied 8051 in class for 5 hours, you should be able to point out the additions/corrections in capitals to the provided code. This is the simplest modification to achieve the operations of Led1 at P3.5, Led2 at P3.6, Led3 at P3.7 and a Button at P3.2(INT0) just as described in the original text.

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.

Comments:
The 10K pullup resistor connected to a Led means that if the Vcc is 5V then just 0.3mA will pass through the Led and it will hardly light up. With 1K pullup the current through the Led is about 3mA and it will shows enough light. With 330R pullup the current through the Led is about 9 mA and will glow bright. Of course that depends of the type of Led and Vcc.
The max levels of the specific MCU are given in the datasheet of [t89c51ac2]
http://www.atmel.com/dyn/resources/prod_documents/doc4127.pdf
The WAIT in the Interrupt Service Routine is a simple way for stepping.

              PROGRAM robo51.IAR
#include <io51.h> 
              ORG 0000H                ;// RESET VECTOR //
              sjmp INIT
interupt:	
              ORG 0003H                ;// INT0 vector address //
              mov P3, #0bfh            ;// turn on ONLY led 3.6//
INT0WAIT:
              jnb P3.2, INT0WAIT       ;// WAIT FOR BUTTON RELEASE STEPPING//
              reti                     ;// return to program //

              ORG 0030H                ;// START main program //
INIT:
              mov IE, #81h             ;// enables interrupts and enable external 0 interupt//
start:				
              mov P3, #0dfh            ;// turn on ONLY led p3.5//
              acall Delay              ;// delay //
              mov P3, #7fh             ;// turn on ONLY led p3.7 //
              acall Delay              ;// delay //
              sjmp start               ;// jump to start //
Delay:
              mov r7, #0fh             ;// 2nd register of delay //
d1:           mov r6, #0ffh            ;// 1st register of delay //
d2:           djnz r6, d2
              djnz r7, d1
		
              END
 

The code checked using IAR Assembler for 8051.
If you decide to use more features of the microcontroller the proper <io___.h> should be used.


K.Angelis



List of 6 messages in thread
TopicAuthorDate
t89c51ac2 interrupt            01/01/70 00:00      
   Classmate?            01/01/70 00:00      
      doesn't this seem peculiar?            01/01/70 00:00      
   Cristmas gift            01/01/70 00:00      
   Just for startup to 8051 mcu            01/01/70 00:00      
   Robo51; Robo-51            01/01/70 00:00      

Back to Subject List