p-5

 5a

org 0000h

sjmp 30h

org 30h

mov a,#34h

ACALL double

here:sjmp here

 double: ADD A,#0E0h

LCALL invert

ret

org 5000h

 invert: XRL a,#0ffh

ret

end


5b


org 0000h

sjmp start

 Start: clr P1.0 ; p1.0=0(low)

 back: cpl P1.0

acall delay

sjmp back

 delay: mov r4,#0e5h ; this count generates a delay of 0.5 ms 

 here: djnz r4,here

 ret

 end


5c

a). (Generate a delay of 1ms) 

org 0000h

 Sjmp 30h

 org 30h

 mov tmod ,#10h ;configure timer 1 in mode 1

 clr p1.1

mov th1,#0fch ;this count gives a delay of 1ms.

 mov tl1,#66h

cpl p1.1

 Setb tr1 ; start timer 

here: jnb tf1, here

clr tf1

clr tr1

clr p1.1

 next: sjmp next

end


(b) Generate a square wave of 2KHz frequency (each delay of 0.25ms)

org 0000h

Sjmp start

 Start: mov tmod ,#20h ;configure timer 1 in mode 2(auto reload)

 mov th1,#1ah ;this count gives a delay of 1ms.

 clr p1.1

 next: cpl p1.1

 Setb tr1 ; start timer

 here: jnb tf1, here

clr tf1

sjmp next

 end


5d.Write an ALP to transfer data serially at 4800 baud rate continuously.

Check the output on serial window1.

org 0000h

sjmp start

Start: mov tmod,#20h ;configure timer 1 for the given baud rate

mov th1,#0fah

mov scon,#50h ; configure UART for mode 1 serial data transfer

setb tr1

repeat: mov dptr,#mes ; DPTR points to mem loc which contains message to be 

 ;transmitted 

again: mov a,#00h

movc a,@a+dptr ; get a character and transmit 

jz skip

acall trans

inc dptr

sjmp again

trans: mov sbuf,a ;serial data transfer

here: jnb ti,here

clr ti

ret

skip: sjmp repeat

org 100h

mes: db"welcome ",0h ; message

end



Comments

Popular posts from this blog

p-3

p-2