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).
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 Program in C++ Using a structure (struct) for a timeType, create a program to...
write a Program in C++ Using a structure (struct) for a timeType, create a program to read in 2 times into structures, and call the method addTime, in the format: t3 = addTime(t1, t2); Make sure to use add the code to reset and carry, when adding 2 times. Also, display the resultant time using a function: display(t3);
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...
Can you solve this C program by using Function? Q1. Write a C program to ring...
Can you solve this C program by using Function? Q1. Write a C program to ring the computer bell at any number of times you specify. Use the system clock as a delay, you need to include the time header file.
write C++ program using functions (separate function for each bottom) Write a program to find if...
write C++ program using functions (separate function for each bottom) Write a program to find if a number is large word for two given bottom base - bottom1 and bottom2. You can predict that a number, when converted to any given base shall not exceed 10 digits. . the program should ask from user to enter a number that it should ask to enter the base ranging from 2 to 16 after that it should check if the number is...
write a c++ program using micro soft visual studio 2010 to write a program and store...
write a c++ program using micro soft visual studio 2010 to write a program and store 36 in variable x and 8 in variable y. add them and store the result in the variable sum. then display the sum on screen with descriptive text. calculate the square root of integer 36 in x. store the result in a variable. calculate the cube root of integer 8 in y. store result in a variable. display the results of square root and...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT