Hi ppl,

im working on my PIC basic pro project to generate 3 channel pwm using PIC 16f737 family and i found some coding from previous thread. i test it and it works well.
but the PWM generated used fixed value of duty cycle and i want to change into customize duty cycle by using lookup command in PICBAsic pro .

my lookup table is below:

For DUTY1 = 0 TO 44

LookUp DUTY1, [0,18,35,53,70,87,104,120,135,150,164,177,190,201,2 11,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

next DUTY1

and here is my 3 channel coding:

ClearWDT

DEFINE OSC 20
' Word vars for 10-bit value of each PWM duty cycle
Duty1 VAR WORD ' Channel #1
Duty2 VAR WORD ' #2
Duty3 VAR WORD ' #3

' Set CCPx pins to outputs
TRISC.2=0 ' CCP1 output
TRISC.1=0 ' CCP2 output (could also be assigned to RB3)
TRISB.5=0 ' CCP3 output

' Set CCP modules to PWM mode
CCP1CON = %00001100 ' Mode select = PWM
CCP2CON = %00001100 ' Mode select = PWM
CCP3CON = %00001100 ' Mode select = PWM

' Set period up for 1.22kHz PWM freq
PR2 = 249

' Set TMR2 up for 1:16 prescale & turn it on
T2CON = %00010101 ' TMR2 ON 1:16 prescale

Duty1 = 512 ' 50% duty cycle. 1024/2 "10-bit resolution"
CCP1CON.4 = Duty1.0 ' Setup 10-bit duty cycle as
CCP1CON.5 = Duty1.1 ' a 10-bit word
CCPR1L = Duty1 >> 2

Duty2 = 512
CCP2CON.4 = Duty2.0
CCP2CON.5 = Duty2.1
CCPR2L = Duty2 >> 2

Duty3 = 512
CCP3CON.4 = Duty3.0
CCP3CON.5 = Duty3.1
CCPR3L = Duty3 >> 2

End


and my problem is i cannot combine the lookup command and the 3channel coding to generate the customize duty cycle ??
can any1 help explaning how?

thanks
photoelectric