I change to 4 mhz AND The Frequency TO 100 ,but the hpwm still on rb.0
INCLUDE "modedefs.bas" ' Include serial modes
@ DEVICE MCLR_ON, XT_OSC, WDT_OFF, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_OFF ,CCPMX_ON
define OSC 4
OPTION_REG = $7f ' Enable PORTB pullups= %01111111
ANSEL = %10000001 ' 'Set PORTA.0 analog rest digital
ADCON1 = %10000000 'Right justify result
ADvalue VAR WORD
DutyCycle VAR WORD $22
Frequency VAR WORD
TRISA = %10000001
TRISB = %10000000
PORTB = 0
'LOW PORTB.0
'LOW PORTB.3 ; Set CCP1 pin to output low
Frequency = 100
DutyCycle = 50
PAUSE 500
loop:
if portb.7 = 0 then
goto left
else
goto right
endif
'=============================
left:
if portb.7 = 1 then right
LOW PORTB.3
@ DEVICE pic16F88, XT_OSC , CCPMX_ON
PAUSE 100 ' start-up delay
TRISB=0
DEFINE CCP1_REG PORTB
DEFINE CCP1_BIT 3
HPWM 1, DutyCycle, Frequency
GOTO left
'=============================
right:
if portb.7 = 0 then left
LOW PORTB.0
@ DEVICE pic16F88, XT_OSC , CCPMX_OFF
PAUSE 100 ' start-up delay
TRISB=0
DEFINE CCP1_REG PORTB
DEFINE CCP1_BIT 1
HPWM 1, DutyCycle, Frequency
GOTO right
'============================
goto loop
END




Bookmarks