Code:
Main:
'Set up a loop for 45 iterations, Duty1 will count 0,1,2,3,4....44
For DUTY1 = 0 TO 44
'Go into the table and retrieve the value pointed at by Duty1 and put that value in Duty2
LookUp DUTY1, 0,18,35,53,70,87,104,120,135,150,164,177,190,201,211,221,229,236,_
243,247,251,254,255,254,251,247,243,236,229,221,21 1,201,189,_
177,164,150,135,120,104,87,70,53,35,18,0],DUTY2
'Duty2 now contains the value from the lookup table that Duty1 points at. First time thru the loop it's 0 second time it's 18 and so on.
CCP1CON.4 = Duty2.0 ' Setup 10-bit duty cycle as
CCP1CON.5 = Duty2.1 ' a 10-bit word
CCPR1L = Duty2 >> 2
Pause 10 'Use each dutycycle value 10ms before going to the next one.
NEXT DUTY1
Goto Main 'And do it all over again
Perhaps I don't understand the problem you're having? Have you actually tried it?
Bookmarks