hsa.a
Junior Member level 3
Hello there,
i have been trying to accomplish the following task for about a week and couldn't get the 1st part of it to run in a loop. kindly help me debug the program in assembly language.
1- Power on the system auto blinks led 1 at 1hz
2- Microcontroller switch connected to int0 is pressed:
a. led1 should halt the routine loop & led 2 should start blinking at 2hz
b. At the same time, the circuit should send “ON” on HyperTerminal.
c. After that LED1 should resume blinking at 1HZ as usual.
3- On subsequent button press item “a” should repeat and item b should switch to “OFF”.
4- Cycle should repeat b/w “ONN & OFF”
P.S: Immediate printing
following is the bugged code. it doesnt return from printing "ON". I always have to reset the circuit manually.
any help will be much appreciated. thank you
i have been trying to accomplish the following task for about a week and couldn't get the 1st part of it to run in a loop. kindly help me debug the program in assembly language.
1- Power on the system auto blinks led 1 at 1hz
2- Microcontroller switch connected to int0 is pressed:
a. led1 should halt the routine loop & led 2 should start blinking at 2hz
b. At the same time, the circuit should send “ON” on HyperTerminal.
c. After that LED1 should resume blinking at 1HZ as usual.
3- On subsequent button press item “a” should repeat and item b should switch to “OFF”.
4- Cycle should repeat b/w “ONN & OFF”
P.S: Immediate printing
following is the bugged code. it doesnt return from printing "ON". I always have to reset the circuit manually.
Code:
ORG 000H
sjmp main
ORG 000BH; interrupt TIIMER routine
PUSH ACC;
SETB P1.4;
SETB P1.5;
POP ACC;
RETI;
ORG 0003H;
LJMP loop;
ORG 00F0H
MS:DB 13,10,"ON",10,13,0
ORG 00F9H
MS1: DB 13,10, "OFF",10,13,0
ORG 030H
main:
MOV IE,#10000011B;
MOV TMOD,#29H; '9600BAUD RATE,8-BIT,1-STOP BIT;;;;;;;;;;;;;;
MOV TH1,#0FDH;
MOV SCON,#50H ;01010000b
SETB TI; ; TRANSMIT BIT HIGH, TRANSMITS WHEN LOW
setb TR1;
start:
sjmp subloop1;
SJMP MAIN;
subloop1:
CLR P1.5;
setb p1.4;
MOV R0,#4; BLINK LOOP ON OFF
ACALL BLINK
JNB INT0,loop
BLINK:
START1:
MOV R1,#25; LOOP FOR REPEATING COUNT
RPT: ;1 sec DELAY
MOV TL0,#0H;
MOV TH0,#0H;
SETB TR0;
AGAIN:
JNB TF0, AGAIN;
CLR TR0;
CLR TF0;
DJNZ R1,RPT;
CPL P1.5;
DJNZ R0,BLINK;
LJMP MAIN;
loop:
setb p1.5;
mov R3,#4;
BL:
MOV R4,#30; LOOP FOR REPEATING COUNT
LRPT: ;2 sec DELAY
MOV TL0,#0H;
MOV TH0,#0H;
SETB TR0;
LAGAIN:
JNB TF0, LAGAIN;
CLR TR0;
CLR TF0;
DJNZ R4,LRPT;
CPL P1.4;
DJNZ R3,BL;
CLR A
SJMP DISPLAY1
DISPLAY1: ;displays ON
setb p1.4
MOV DPTR,#MS;
MOV R4,3
dis:
CLR A
MOVC A,@A+DPTR;
JZ S1;
acall TRANS
S1:SJMP S1;
ret;
TRANS:
MOV SBUF, A;
JNB TI,$
CLR TI
INC DPTR;
DJNZ R4,dis;
reti;
END;