Thanks ! You fix all my problems ! 
However i have another question about this code and the function PWM...
How to have multiple pwms output ?
take a look to the following code
Code:
@ __CONFIG _CONFIG1L, _PLLDIV_3_1L & _CPUDIV_OSC1_PLL2_1L
@ __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
@ __CONFIG _CONFIG2L, _VREGEN_OFF_2L
@ __CONFIG _CONFIG2H, _WDT_OFF_2H
@ __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
DEFINE OSC 48
led VAR PORTD
'changed WORD for BYTE ... using 32bit int for 8bit value is taking more cycle to do operation to it
step0 VAR byte
step1 VAR byte
step2 VAR byte
step3 VAR byte
step4 VAR byte
step5 VAR byte
step6 VAR byte
step7 VAR byte
cycles CON 2
' Change limits for steps to play around 0 or 100% brightness
' Change steps for different duration of ramps
' Works good even with high brightness LEDs, harder to control linearly
fade:
For step0=0 TO 100
PWM led.0,step0,cycles
Next
For step1=0 TO 100
PWM led.1,step1,cycles
Next
For step2=0 TO 100
PWM led.2,step2,cycles
Next
For step3=0 TO 100
PWM led.3,step3,cycles
Next
For step4=0 TO 100
PWM led.4,step4,cycles
Next
For step5=0 TO 100
PWM led.5,step5,cycles
Next
For step6=0 TO 100
PWM led.6,step6,cycles
Next
For step7=0 TO 100
PWM led.7,step7,cycles
Next
For step0=100 TO 1 STEP -1
PWM led.0,step0,cycles
Next
For step1=100 TO 1 STEP -1
PWM led.1,step1,cycles
Next
For step2=100 TO 1 STEP -1
PWM led.2,step2,cycles
Next
For step3=100 TO 1 STEP -1
PWM led.3,step3,cycles
Next
For step4=100 TO 1 STEP -1
PWM led.4,step4,cycles
Next
For step5=100 TO 1 STEP -1
PWM led.5,step5,cycles
Next
For step6=100 TO 1 STEP -1
PWM led.6,step6,cycles
Next
For step7=100 TO 1 STEP -1
PWM led.7,step7,cycles
Next
GoTo fade
End
What i want is to fade ON all led each by each while keeping them ON
then after Turn them OFF (while fading) one by one
The code only do pwm on 1 led at time only :S
Any clues ?
oh btw, searching through the forum is PITA ... it doesn't take words like PWM , because it's too short ... hence rendering the search practically useless for "Multiple PWM"
Cheers,
Best Regards,
Laurent
Bookmarks