Question

In: Computer Science

Using P18f4580 controller - Write a program in C using Timer0 to generate a square wave...

Using P18f4580 controller - Write a program in C using Timer0 to generate a square wave with a frequency of 1kHz on PORTBRB5? (Assume XTAL = 20 MHz).

Solutions

Expert Solution

The P18f4580 PROGRAM TO GENERATE A SQUARE QAVE OF FREQUENCE 1KHZ ON PORTBR5 is given as follows:

----------------------------------------------------------------

Program:
#include <p18F458.inc>
    ORG 0x00
    GOTO START
   ORG 0x30
START BCF TRISB,4
   MOVLW 0x08
         MOVWF T0CON
HERE MOVLW 0xFB
   MOVWF TMR0H
   MOVLW 0x1E
   MOVWF TMR0L
   BCF INTCON,TMR0IF
   CALL DELAY
   BTG PORTB,RB5
   BRA HERE
DELAY BSF T0CON,TMR0ON
AGAIN BTFSS INTCON,TMR0IF
   BRA AGAIN
   BCF T0CON,TMR0ON
   RETURN
   END

----------------------------------------------------------

So, the program above generates a square wave on PORT RB5.

--------------------------------------Please Upvote-----------------------------------------------------------------------------------


Related Solutions

Using P18f4580 controller - Write a program in C using Timer1 and the largest prescaler possible...
Using P18f4580 controller - Write a program in C using Timer1 and the largest prescaler possible to generate a square wave with a frequency of 2.5kHz on PORTC RC5? (Assume XTAL = 20 MHz).
C++ Visual Studio 2019 Part A : Program Description: Write a program to generate a report...
C++ Visual Studio 2019 Part A : Program Description: Write a program to generate a report based on input received from a text file. Suppose the input text file student_grades.txt contains the student’s Last name , First name, SSN, Test1, Test2, Test3 and Test4. (25%) i.e. Alfalfa   Aloysius   123-45-6789 40.0    90.0   100.0    83.0 Generate the output Report File student_final.txt in the following format : LastName FirstName   SSN Test1   Test2   Test3   Test4 Average FinalGrade i.e. Alfalfa   Aloysius   123-45-6789 40.0    90.0   100.0   ...
Write a program using c++. Write a program that uses a loop to keep asking the...
Write a program using c++. Write a program that uses a loop to keep asking the user for a sentence, and for each sentence tells the user if it is a palindrome or not. The program should keep looping until the user types in END. After that, the program should display a count of how many sentences were typed in and how many palindromes were found. It should then quit. Your program must have (and use) at least four VALUE...
Write a C# console program that fills the right to left diagonal of a square matrix...
Write a C# console program that fills the right to left diagonal of a square matrix with zeros, the lower-right triangle with -1s, and the upper left triangle with +1s. Let the user enter the size of the matrix up to size 21. Use a constant and error check. Output the formatted square matrix with appropriate values. Refer to the sample output below. Sample Run: *** Start of Matrix *** Enter the size of square (<= 21): 5 1 1...
Write a C++ program to ask the user to enter the shape type: square, sphere or...
Write a C++ program to ask the user to enter the shape type: square, sphere or circle and the appropriate dimensions of the shape.. The program should output the following information about the shape: a.for a square. it output the area and perimeter. b. for a sphere, it outputs the area. c. fir a circle, it outputs the volume. if the user input anything else, your program should output: "the program does not recognize this shape". Use const whenever it...
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.
E10.15 Use the LTC1661 from Linear Technology to generate a two-frequency square wave   from the VOUTA...
E10.15 Use the LTC1661 from Linear Technology to generate a two-frequency square wave   from the VOUTA pin. The frequency alternates between 1 and 4 kHz every 4 s.
E10.15 Use the LTC1661 from Linear Technology to generate a two-frequency square wave   from the VOUTA...
E10.15 Use the LTC1661 from Linear Technology to generate a two-frequency square wave   from the VOUTA pin. The frequency alternates between 1 and 4 kHz every 4 s.
Write a simple C program to generate a chart of circle properties. Output chart “iteration” is...
Write a simple C program to generate a chart of circle properties. Output chart “iteration” is to be specified by user input. Your chart will include the radius, diameter, circumference, and Area values in a single table, and radius values will range from 0 to 50, floating point values, with three-decimal-place precision. Table should have all column entries right-justified and each column will have a heading above the entries. For example, assuming user enters a incrementation value of 5, the...
write c program to generate 6 numbers to simulate rolling of a dice . use while...
write c program to generate 6 numbers to simulate rolling of a dice . use while loop to run 100 and 10000 times. print out how many times it generates 1, 2,3,4,5,6.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT