can anyone plz help me again?
today i hooked up the circuit to test the HPWM feature of the PIC16F877 but it doesnt seem to be work properly.
my testing code is shown below:
ADCON1=7
TRISA=31
TRISC=0
LOOP:
HPWM 1,0,0 'DUTYCYLE 0%
IF PORTA.0=1 Then 'CHECK PIN 0 STATE
HPWM 1,191,20000 'OUPUT 75% DUTYCYLE 20KHZ
EndIF
IF PORTA.1=1 Then 'CHECK PIN 1 STATE
HPWM 1,127,20000 'OUTPUT 50% DUTYCYLE 20KHZ
EndIF
GOTO LOOP
END
What's wrong with the code? i just want to output certain frequency on pin RC2 when port A pins receive signal, but it doesnt work properly.
by using the oscillosocpe, i can see that the output is not a pure square wave, but is distorted. the frequency is only 50Hz!!!! the duty cycle doenst change at all.
is that anything wrong with the code? plz help me.my motor circuit wont run without it..
in this case,do i need to pull down all the unused pins?i only use two pins to detect signal and one pin as an output?
i connect the PIC based on the following diagram. but i also saw slightly different type of connection at **broken link removed**
they dont connect both Vcc and Vdd. which one is correct connection?