Need help in PWM code

Status
Not open for further replies.

Sheritronics

Newbie level 6
Joined
Feb 1, 2014
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
80
Code:
	org 0x00
	include <P16F877A.inc>
test equ 0x20
setup 	
		bsf     STATUS,5
		movlw   0x01
		movwf   TRISB
		clrf    TRISC
		bcf     STATUS,5
		clrf    PORTB
		clrf    PORTC
		movlw   D'60'
 		movwf   CCP1CON
		movlw   D'7'
 		movwf   T2CON
		movlw	D'163'
		movwf   CCPR1L
		banksel PR2
 		movlw   D'200'
 		movwf   PR2
		clrf	test
 	
loop

 	btfss  PORTB,0
	goto   loop

testing
	btfss  test,0
	goto   percent_50
	goto   percent_82


percent_50				
		movlw   D'99'
 		movwf   CCPR1H
		comf    test
		goto    loop


percent_82
		movlw 	D'163'
		movwf	CCPR1H
		comf    test
		goto    loop
 	   
		 end

- - - Updated - - -

I have a to generate a PWM signal of 934Hz and control between two speeds thats 50% duty cycle when i press the button and then on pressing it again it will switch back to 82% duty cycle
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…