Question

In: Electrical Engineering

Write the code in assembly language to generate two square waves of frequency 1KHZ with 50%...

Write the code in assembly language to generate two square waves of frequency 1KHZ with 50% duty cycle and 10KHZ with 50% duty cycle using P1.0 and P1.1 using timer0 and timer1 simultaneously. Don't use instruction overhead. use timer interrupts to implement the functionality use Xtal=12MHZ

Solutions

Expert Solution

I am assuming you are talking about 8051 microcontrollers.

Given Crystal Frequency = 12MHz., that means 1 clock pulse is of 1μsec.

1st frequency required = 1KHz

1 pulse = 1/1KHz = 1 msec, 500 μsec ON time and 500 μsec OFF time

Count = 500μsec/1μsec = 500

Counter initial value = 65536 - 500 = 65036 = FE0C

for 10Khz,

1 pulse = 1/10KHz = 0.1msec

Counter initial value = 50 usec/1 usec = 50

Counter intial Value = 65486 = FFCE

We can use the timer in MODE 1(counter mode - 01)

Finding TMOD bit:

TMOD = 0001 0001 -> (11)H (we are using both timers, one for 1KHz and other for 10Khz)

Now we need to produce 2 interupts for TIM 1 AND TIM2, so we need to ask IE register:

1000 1010 - (8A)H

PROGRAM :

org 0000H
LJMP main
org 000BH
CPL P1.0
CLR TR0
CPL P1.1
CLR TR1
MOV TL0 #0CH
MOV TL0 #0FEH
SETB TR0
SETB TR1
RETI
org 0100H
MOV 1E #8A
MOV TMOD #11H
MOV TL0 #0CH
MOV TH0 #0FEH
MOV TL1 #
SETB TR0
SETB TR1
SJMP TR0
SJMP TR1


Related Solutions

Write a MIPS assembly language to transpose a square integer matrix in code
Write a MIPS assembly language to transpose a square integer matrix in code
Generate a signal composed of two square waves, the first has a 14 Hz and the...
Generate a signal composed of two square waves, the first has a 14 Hz and the second has a 55 Hz frequency. Both waves are sampled at 2 kHz for 200 ms. Duty cycle for the first wave is 40% while the second’s is 35%. Show the signal with and without adding white Gaussian noise with a variance of 1/100 in matlab
Write hack assembly language code for eq lt gt
Write hack assembly language code for eq lt gt
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code that transmits a single character and lights the red LED upon receiving that character. The board will "talk" to itself. The green LED should turn on whenever a message is sent and the LCD will display the message being received.
write a assembly language program to convert GRAY to BCD code in 8051
write a assembly language program to convert GRAY to BCD code in 8051
This is to be done with MIPS assembly language. Write MIPS code which is equivalent to...
This is to be done with MIPS assembly language. Write MIPS code which is equivalent to the follow java program: int day = (int)(Math.random() * 7); switch (day) { case 1: System.out.println(“Monday”); break case 2: System.out.println(“Tuesday”); break case 3: System.out.println(“Wednesday”); break case 4: System.out.println(“Thursday”); break case 5: System.out.println(“Friday”); break case 6: System.out.println(“Saturday”); break case 0: System.out.println(“Sunday”); break }
Need to code this is assembly language. Using the windows32 framework, write a procedure to read...
Need to code this is assembly language. Using the windows32 framework, write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the output...
Write an assembly language program code to clear and set bit 7th and 19th in a...
Write an assembly language program code to clear and set bit 7th and 19th in a 32-bit variable called N.
Using x86 assembly language, create a flowchart and write an example of code that will sort...
Using x86 assembly language, create a flowchart and write an example of code that will sort 2 arrays of unsigned doubleword integers in ascending order and output the largest element in each array. Any sorting procedure can be used, but this procedure must be called twice for each array. The first time it is called, the first array should be sorted and the second time it is called, the second array must be sorted. As well as outputting which is...
You must write the code in 80x86 assembly language and must attach a screenshot of the...
You must write the code in 80x86 assembly language and must attach a screenshot of the output. # Pennies for Pay Write a program that calculates how much a person earns in a month if the salary is one penny the first day, two pennies the second day, four pennies the third day, and so on with the daily pay doubling each day the employee works. The program should ask the user for the number of days the employee worked...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT