Where and how are your symbols defined ? Where and how are the analog pins setup ? Harry H. Arends wrote: > I have made some code to produce two pwm's to let two led's fade in > and fade out. > It looks to work but the outputs are never been set. Am i missing > somethin? > The PIC used is a 16F685 and i am using MPLAB IDE 8.30 as development > tool. > > [code] > movlw d'2' ; init slope counter > movwf ACC_COUNT > > movlw 0x0F > movwf CV545 > movlw 0x03 > movwf CV515 > clrf PWM1A > clrf PWM1B > ; > ---------------------------------------------------------------------- > MainLoop: > > F1A_Set: ; If B is on then fade out > ; then fade A in else A in > clrf SPEED1B ; turn off > bcf DIR_UP,OUT1B > bcf LIGHT_UP,OUT1B > btfss DIR_UP,OUT1A ; if lights, nothing to do > bsf LIGHT_UP,OUT1A ; next light this > call DoLight1 > F1B_Set > clrf SPEED1A ; turn off > bcf DIR_UP,OUT1A > bcf LIGHT_UP,OUT1A > btfss DIR_UP,OUT1B ; if lights nothing to do > bsf LIGHT_UP,OUT1B ; next light this > call DoLight1 > goto MainLoop > > DoLight1: > decfsz ACC_COUNT,f ; slope > goto SpeedOn > > movf CV545,w ; load slope from CV > movwf ACC_COUNT > > movf PWM1A,w ; all off? > iorwf PWM1B,w > btfss STATUS,Z > goto DoPWM1A > DoLight1A: > btfss LIGHT_UP,OUT1A ; realy do lightA > goto DoLight1B > bcf LIGHT_UP,OUT1A > bsf DIR_UP,OUT1A ; If so set max light > movf CV515,w > movwf SPEED1A > DoLight1B: > btfss LIGHT_UP,OUT1B ; realy do LightB > goto DoPWM1A > bcf LIGHT_UP,OUT1B > bsf DIR_UP,OUT1B ; If so set max light > movf CV515,w > movwf SPEED1B > > DoPWM1A: > movf PWM1A,w ; calc PWM acc/dec > xorwf SPEED1A,w > btfsc STATUS,Z > goto DoPWM1B > movlw 0x01 > btfss DIR_UP,OUT1A > movlw 0xFF > addwf PWM1A,f > DoPWM1B: > movf PWM1B,w > xorwf SPEED1B,w > btfsc STATUS,Z > goto DoLight1 > movlw 0x01 > btfss DIR_UP,OUT1B > movlw 0xFF > addwf PWM1B,f > goto DoLight1 > > SpeedOn: > clrf OUTPUT ; do PWM of outputs > rrf TMR1H,w > rrf TMR1L,w > movwf TIMER > bcf STATUS,C > rrf TIMER,w > btfsc TMR1H,1 > iorlw 0x80 > iorlw 0x0F > > movwf TIMER > addwf PWM1A,w > btfsc STATUS,C > bsf OUTPUT,OUT1A > movf TIMER,w > addwf PWM1B,w > btfsc STATUS,C > bsf OUTPUT,OUT1B > movf OUTPUT,W > xorwf PORTC, W > andlw (1< xorwf PORTC, F ; > > movf PWM1A,w ; If either one is zero > iorwf PWM1B,w > btfsc STATUS,Z ; do it again > goto DoLight1 > > movf CV518,w ; where doing PWM now > xorwf PWM1A,w ; and keep doing so until > xorwf PWM1B,w ; the value in CV518 is > btfsc STATUS,Z ; reached > return ; Light should be on > goto DoLight1 > [/code] > > Any help would be welkom. Regards > > Harry > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist