Download Microcontroller & Interfacing - Biomedical Department
Transcript
Program: Write a program to rotate DC motor connected in above circuit such that when switch SW1 is pressed, motor rotates in clockwise direction and when SW2 is pressed, motor rotates in anti-clockwise direction. Use external interrupts for the program. ORG 00h AJMP START ORG 03h ; Vector location for external interrupt 0 SETB P1.1 ; Rotate motor in clockwise direction CLR P1.0 ; -- do -RETI ORG 13h ; Vector location for external interrupt 1 SETB P1.1 ; Rotate motor in anticlockwise direction CLR P1.0 ; -- do -RETI START: CLR P1.0 ; Make P1.0 output pin CLR P1.1 ; Make P1.1 output pin CLR P1.2 ; Make P1.2 output pin MOV IE,#85h ; Enable external interrupt 0 and 1 SETB IT0 ; Negative edge triggered interrupt SETB IT1 ; Negative edge triggered interrupt SETB P1.0 ; Enable chip L293 (H-bridge) HERE: SJMP HERE :: WORKSHEET :: A. Modify previous program without using interrupts. (Hint: using polling method to check whether switch is pressed or not like JNB P3.2, clockwise.) Memory HEX Label Opcode Operands Comments Location code BM Dept., Govt. Engg. College, Gandhinagar Page 69