In: Computer Science
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).
The C program for P18f4580 IS USED TO GENERATE A SQUARE WAVE ON PORT RC5 this is given as follows:
----------------------------------------------Code-----------------------
#include <p18F458.inc>
ORG 0x00
GOTO START
ORG 0x30
START BCF TRISB,5
MOVLW 0x30
MOVWF T1CON
HERE MOVLW 0xFF
MOVWF TMR1H
MOVLW 0xCB
MOVWF TMR1L
BCF PIR1,TMR1IF
CALL DELAY
BTG PORTB,RC5
BRA HERE
DELAY BSF T1CON,TMR1ON
AGAIN BTFSS PIR1,TMR1IF
BRA AGAIN
BCF PIR1,TMR1ON
RETURN
END
--------------------------------------------------------------------------------------------------------------
The code generates a square wave on port RC5.
----------------------------------------Please Upvote--------------------------------------------------------------------------------------