Question

In: Electrical Engineering

Write a program using interrupts to get data serially and send it to P2 while at...

Write a program using interrupts to get data serially and send it to P2 while at the same time Timer 0 is generating a square wave of 5 kHz. We've been basing our code on the Intel 8051 microntroller and assembly language.

Solutions

Expert Solution

ORG 0

  LJPM MAIN

  ORG 000BH ;ISR for Timer 0

  CPL P0.1 ; toggle P0.1

  RETI

  ORG 23H

  LJPM SERIAL ; jump to serial int. ISR

  ORG 30H

MAIN: MOV P1, #OFFH ; make P1 an input port

MOV TMOD, #22H ; timer 0&1, mode 2, auto-reload

  MOV TH1, #0F6H ; 4800 baud rate

  MOV SCON, #50H ; 8-bit, 1 stop, REN enabled

  MOV THO, #-92 ; for 5 KHZ wave

  MOV IE, #10010010B ; enable serail, timer 0 int.

  SETB TR1 ; start timer 1

  SETB TR0 ; start timer 0

BACK: MOV A, P1 ; read data from port 1

  MOV SBUF, A ; give a copy to SBUF

  MOV P2, A ; write it to P2

  SJMP BACK ; stay in loop indefinitely

SERIAL PORT ISR

ORG 100H

SERIAL: JB TI, TRANS ; jump if TI is high

MOV A, SBUF ; otherwise due to received

MOV P0, A ; send serial data to P0

CLR RI ; clear RI since CPU does not

RETI ; return from ISR

TRANS: CLR TI ; clear TI since CPU does not

  RETI ; return from ISR

END


Related Solutions

Write C18 program to get bit RB3 and send it to RC2.
Write C18 program to get bit RB3 and send it to RC2.
C++ (data structure using c++). please send me copyable file. Write a program and test a...
C++ (data structure using c++). please send me copyable file. Write a program and test a program that translates the following Bubble Sort algorithm to a bubblesort function. The function's prototype is, void bubblesort(int a[], int size); Bubble Sort The inner loop moves the largest element in the unsorted part of the array to the last position of the unsorted part of the array; the outer loop moves the last position of the unsorted part of the array. The Bubble...
Multiples of 2 and 3: write a c++ program Using a while loop, write a program...
Multiples of 2 and 3: write a c++ program Using a while loop, write a program that reads 10 integer numbers. The program shall count how many of them are multiples of 2, how many are multiples of 3, and how many are NOT multiples of either 2 or 3. The output should be similar to the one shown below.
1 for each of the problems listed below write the c++ program while using WHILE loop...
1 for each of the problems listed below write the c++ program while using WHILE loop structures A program will display each term in the following sequence 1 -10 100 -1000 10000 -100000 1000000 A program will calculate and display the corresponding celsius temperatures for the given Farenheit ones from 0f to 212 f (hint c=(f-32/1.8)
(Using Matlab) and "while" function 1.   Write a program that prompts the User for if they...
(Using Matlab) and "while" function 1.   Write a program that prompts the User for if they would like to enter a real number. If yes, prompt the User for the real number. Continue to do this until the User enters “no” to the first question. After the User enters “no”, display the average of all the numbers entered. (Using Matlab) and "while" function 2.   Write a program that prompts the User for if they would like to enter a real...
Write a program in PYTHON, using a while loop, that asks the user to enter the...
Write a program in PYTHON, using a while loop, that asks the user to enter the amount that they have budgeted for the month. The program should then prompt the user to enter their expenses for the month. The program should keep a running total. Once the user has finished entering their expenses the program should then display if the user is over or under budget. The output should display the monthly budget, the total expenses and whether the user...
Write a program in c++ using only while and for loops . Use of arrays and...
Write a program in c++ using only while and for loops . Use of arrays and functions is not allowed. Given the first value, generate the next ten terms of the sequence like 1, 2, 4, 8, 16, 22, 26, 38, 62, 74, 102, 104, … Explaination with code is required.
QUESTION Write the main while loop for a Java program that processes a set of data...
QUESTION Write the main while loop for a Java program that processes a set of data as follows: Each line of the input consists of 2 numbers representing a quantity and price. Your loop should: 1. Read in the input 2. Calculate the tax. Tax will be 8.875% of price and will only be applicable if price is more than 110. Calculate the new price which is the price plus tax. 3. Calculate the final price by multiplying quantity by...
*****Using Java Write a program that finds the standard deviation while also using a graphical user...
*****Using Java Write a program that finds the standard deviation while also using a graphical user interface.
Write a Java program using using WHILE loop to find the sum of all integers between...
Write a Java program using using WHILE loop to find the sum of all integers between 200 to 250 which are divisible by 7. Sample Output: Numbers between 200 and 250, divisible by 7: 203 210 217 224 231 238 245 The sum is: 1568
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT