neazoi
Advanced Member level 6
- Joined
- Jan 5, 2008
- Messages
- 4,157
- Helped
- 13
- Reputation
- 26
- Reaction score
- 15
- Trophy points
- 1,318
- Location
- Greece
- Activity points
- 37,198
Hello I experiment with a 50% duty cycle square wave generator on a pic16f84.
I am using just a pin as a square wave output.
Using a 4MHz crystal, how can I calculate the output frequency?
My goal is to output 135-137KHz square wave signal.
My code is below
I am using just a pin as a square wave output.
Using a 4MHz crystal, how can I calculate the output frequency?
My goal is to output 135-137KHz square wave signal.
My code is below
Code:
; counter variable
CNT EQU 16 ; uS delay. Modify this, to change frequency
Loop
movlw 1 ; Turn on Port A
movwf PORTA ;
movlw CNT
call MDELAY ; CNT uS delay
movlw 0 ; Turn off the LED on Port A
movwf PORTA ;
movlw CNT
call MDELAY ; CNT uS delay
goto Loop
; delay for w uS. Set the w register to the desired delay value
MDELAY:
MOVWF CNT ;LOAD DELAY TIME
COUNT: NOP ;TWO NO OPERATIONS
NOP ;TO OBTAIN THE DELAY
DECFSZ CNT,1 ;DECREMENT THE COUNTER
GOTO COUNT ;GOTO COUNT IF NOT FINNISHED
RETURN
end
Last edited: