Thankx HenrikOlsson for the comments, and explaination to me
I have been worked on this code for the whole day but still I didi not get any output. The problem I faced is I don't get any output to the CCP1(TRISC<2>).I tryt to put led1 on main to measure the time I get it clear which is 1sec for each toggle which is true( 500+500)ms also I put led1 on UpdateDuty subroutine also I get clear a delay of 500ms to each toggle which is also true because UpdateDuty it is called aftter every 500ms. But I 'm confusing where is problem? And why is CCP1 does not output to (TRISC<2>)?.Here is the code.
Code:
PIC 16F877
define OSC 4
TRISC = %11111011
CCP1CON = %00001100
T2CON = %00000100
PR2 = 199 for 5khz
TRISB = %11111101
TRISA = %11111111
LED1 VAR PORTB.1
temp var word
Main:
Temp = 40
GOSUB UpdateDuty
Pause 500
Temp = 400
GOSUB UpdateDuty
Pause 500
TOGGLE LED1
GOTO Main
UpdateDuty:
CCP1CON.4 = Temp.0 ' bit 0
CCP1CON.5 = Temp.1 ' bit 1
CCPR1L = Temp>>2 'Bit 2-7
RETURN
end
Help me to solve this problem thankx.
Bookmarks