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...
(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...
*****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
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 a while loop. Write a JAVA program that asks a user for an integer between...
Using a while loop. Write a JAVA program that asks a user for an integer between 1 and 9. Using the user input, print out the Fibonaccci series that contains that number of terms. Sample output: How many terms would like printed out for the Fibonacci Sequence? 7 Fibonacci Series of 7 numbers: 0 1 1 2 3 5 8
Q1:Write a Java program to find Fibonacci Series using 1) using for loop 2) using while...
Q1:Write a Java program to find Fibonacci Series using 1) using for loop 2) using while loop To Understand what the Fibonacci series is: The Fibonacci sequence is a series of numbers where a number is the sum of the previous two numbers. Starting with 0 and 1, the sequence goes 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on. Q2: Write a Java program to find the Factorial of a number using a while loop. To...
Write a Java program using jGRASP directions are as follows: Uses a while loop to print...
Write a Java program using jGRASP directions are as follows: Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT