0% found this document useful (0 votes)
14 views14 pages

22bce3350 Task3

The document describes an algorithm to generate square waves of different frequencies using timers 0 and 1 of a microcontroller. It also contains code to transmit strings via UART depending on a condition. Timer 0 is used to count up to 80 and trigger transmission of different strings at 4800 or 9600 baud when the count equals or is less than 80 respectively.

Uploaded by

pandeaditya1507
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views14 pages

22bce3350 Task3

The document describes an algorithm to generate square waves of different frequencies using timers 0 and 1 of a microcontroller. It also contains code to transmit strings via UART depending on a condition. Timer 0 is used to count up to 80 and trigger transmission of different strings at 4800 or 9600 baud when the count equals or is less than 80 respectively.

Uploaded by

pandeaditya1507
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

TASK-3

REG NO. 22BCE3350


STUDENT NAME YALLALA MOHAN SANDEEP REDDY
COURSECODE BECE204P

SLOT & SEMESTER L9+L10


WINTER 2023-2024

COURSE NAME MICROPROCESSORS AND


MICROCONTROLLERS LAB

PROGRAM TITLE TASK-3

DATE OF EXP 05/03/24

DATE OF SUBMISSION 31/03/24

FACULTY NAME Dr. Vivek Rajpoot


AIM: Write an ALP using timer 1, MOD1, to generate a square wave of
frequency ‘3350’ Hz at pin P1.5.

Tools required: keil uvision5


Calculations:
ALGORITHM:
1.Initialize the program counter to address 0000H.
2.Set up Timer 1 in mode 1 (16-bit auto-reload mode).
3.Load the high byte of the initial value (0FFH) into the Timer 1 high register (TH1).
4.Load the low byte of the initial value (77H) into the Timer 1 low register (TL1).
5.Toggle the state of pin P1.5.
6.Call the DELAY subroutine.
7.Jump back to the label HERE to repeat the process indefinitely.
Subroutine DELAY:
8.Set Timer 1 to start counting.
9.Loop until Timer 1 overflow flag (TF1) is set, indicating that the delay period has
elapsed.
10.Clear Timer 1 to stop counting.
11.Clear the Timer 1 overflow flag (TF1).
12.Return from the subroutine.
SIMULATION CODE:
OUTPUT:

AIM: To write an ALP using timer 0, MOD1, to generate a square wave of ‘3.350’
millisecond
.Tools required: keil uvision5

CALCULATIONS:
ALGORITHM:

1.Set the program execution to start at address 0000H with the label HERE.
2.Configure Timer 0 in Mode 1 with MOV TMOD, #01H.
3.Load the value 0F9H into TH0 and TL0 for Timer 0.
4.Complement the bit P1.2 with CPL P1.2.
5.Call the subroutine DELAY with ACALL DELAY.
6.Jump back to the label HERE to repeat the process.
7.Define the subroutine DELAY:
->Set Timer 0 to start counting with SETB TR0.
->Enter a loop labeled as LOOP:
->Check if Timer 0 overflow flag TF0 is set with JNB TF0, LOOP.
->Clear Timer 0 and its overflow flag with CLR TR0 and CLR TF0.
->Return from the subroutine with RET.
8.End the program execution

SIMULATION CODE:
OUTPUT:

AIM: To Write an ALP using timer 0, MOD2, to generate a square wave of frequency
3350 Hz at pin P1.5.
Tools required: keil uvision5

CALUCULATIONS:
ALGORITHM:
1.Set the program execution to start at address 0000H.
2.Configure Timer 0 in Mode 2 with MOV TMOD, #02H.
3.Load the value 077H into TH0 for Timer 0.
4.Start Timer 0 by setting TR0 with SETB TR0.
5.Enter a loop labeled as BACK:
->Check if Timer 0 overflow flag TF0 is not set with JNB TF0, BACK.
->Complement the bit P1.5 with CPL P1.5.
->Clear the Timer 0 overflow flag TF0 with CLR TF0.
->Jump back to the BACK label to repeat the process.
6.End the program execution.

SIMULATION CODE:

OUTPUT:
AIM: To write ALP for the scenario given in this question
Tools required: keil uvision5

ALGORITHM:
1.Set the program execution to start at address 0000H.
2.Configure Timer 1 in Mode 2 with split timer mode using MOV TMOD, #01100000B.
3.Clear the value in TH1 by loading 0 into it with MOV TH1, #0.
4.Set pin P3.5 as an input with SETB P3.5.
5.Enter a loop labeled as AGAIN:
->Start Timer 1 by setting TR1 with SETB TR1.
->Enter a loop labeled as BACK:
->Move the content of TL1 to accumulator A with MOV A, TL1.
->Move the value of A to port P2 for monitoring.
->Check if Timer 1 overflow flag TF1 is not set with JNB TF1, BACK.
->Clear Timer 1 by clearing TR1 and its overflow flag TF1.
->Jump back to the AGAIN label to repeat the process.
6.End the program execution.

CODE:
SIMULATION CODE:

OUTPUT:
AIM: To write ALP for the scenario given in the question
Tools required: keil uvision5

CALCULATIONS:
ALGORITHM:
1.Set the program execution to start at address 0000H.
2.Configure Timer 1 in Mode 2 for baud rate and Counter 0 in Mode 2 for counting cars
using MOV TMOD, #00100110B.
3.Load the value 80D into TH0 for Counter 0 maximum count.
4.Start Counter 0 by setting TR0 and switch on the counter with SETB TR0 and SETB
P3.4.
5.Enter a loop labeled as AGAIN:
->Move the content of TL0 to accumulator A and store it in register R3.
->Clear the accumulator A.
->Compare R3 with 80D, if not equal, jump to LESSTHAN_80; otherwise,
call EQUALS_80.
->Jump back to the AGAIN label to repeat the process.
6.If R3 is less than 80D (LESSTHAN_80):
->Set pin P1.0 to switch on.
->Load -6 into TH1 for baud rate of 4800.
->Start Timer 1 by setting TR1.
->Configure the serial port for full duplex communication with 8-bit data and 1
stop bit.
->Set R1 to 07D (length of "SANDEEP") and DPTR to the starting point of
"SANDEEP" (0100H).
->Enter a loop labeled as TRANSIT:
->Clear the accumulator A.
->Move the data from the address pointed by DPTR to A using MOVC A,
@A+DPTR.
->Call the subroutine TRANS to transmit the data to SBUF.
->Increment DPTR.
->Decrement R1 and repeat until all characters are transmitted.
->Return from the subroutine.
7.If R3 equals 80D (EQUALS_80):
->Load -3 into TH1 for baud rate of 9600.
->Start Timer 1 by setting TR1.
->Configure the serial port for full duplex communication with 8-bit data and 1
stop bit.
->Set R2 to 07D (length of "YALLALA") and DPTR to the starting point of
"YALLALA" (0200H).
->Enter a loop labeled as TRANSMIT:
->Clear the accumulator A.
->Move the data from the address pointed by DPTR to A using MOVC A,
@A+DPTR.
->Call the subroutine TRANS to transmit the data to SBUF.
->Increment DPTR.
->Decrement R2 and repeat until all characters are transmitted.
->Clear Timer 0 overflow flag TF0 and return from the subroutine.
8.Define the subroutine TRANS:
->Move the data from A to SBUF for transmission.
->Wait for the transmission to complete by checking the transmit interrupt flag
TI.
->Clear the transmit interrupt flag TI and return from the subroutine.
9.Define the data "SANDEEP" at address 0100H and "YALLALA" at address 0200H.
10.End the program execution.
SIMULATION CODE:
OUTPUT:

You might also like