Hello everyone, The last time I posted here I got exactly the responses I needed to get= =20 through the thicket, so I thought I'd give it another go. What I'm trying t= o=20 do is initialize (on a 16F913) the PWM unit on this chip (it should output= =20 on RC5) and also turn on the weak pull up on RB2. I've read the data sheet= =20 and followed the directions and tried (hours worth of it) messing with it= =20 myself, but I'm afraid I'm overlooking something.. possibly something basic= .=20 Here is the initialization code i have. For the PWM, regardless of what I= =20 put in CCPR1L and CCP1CON I get the same (always off) duty cycle. On the=20 weak pull ups, once I have it enabled, the default read (with nothing=20 attached) should be '1' but I'm getting zero.=20 Here is what I'm using. Any pointers woudl be greatly appreciated. I hope= =20 the code doesn't cut/paste too sloppily. James =20 INITIALIZATION call Wait300uS ;try to stop from jumping directly into the menu=20 call Wait300uS ;by randomly waiting a bit more before we start testing=20 buttons=20 movlw b'01100101' ;setting internal clock for 4MHz movwf OSCCON ;; interupt enabling=20 MOVLW B'11000000' ; SET GLOBAL & PERIPH INT ENAB MOVWF INTCON ;;turn timer1 off and clear=20 BCF T1CON,0 ; MAKE SURE TIMER1 IS OFF CLRF TMR1H ; CLEAR TIMER1 CLRF TMR1L=20 MOVLW B'00110000' ; SET UP TMR1 WITH 1:8 PRESCALER, INPUT=3DFOSC/4 MOVWF T1CON ; BUT DON'T ENABLE TMR1 YET ;;setting up ports MOVLW B'00000000' ; INITIALIZE PORTS MOVWF PORTB MOVLW B'00000000' MOVWF PORTA MOVLW B'00000000' MOVWF PORTC ;;clearing variables CLRF T1COUNT CLRF FIVE_SEC_CNT ;;switch to bank1 BSF STATUS,RP0 ; SWITCH TO BANK1 BCF STATUS, RP1 ;;tell timer1 to interrupt MOVLW B'00000001' ; SET TMR1 INT ENABLE BIT=20 MOVWF PIE1=20 CLRF PIE2=20 ;;the order of these is in effort to initialize RA3 as a digital Input movlw 07h movwf CMCON0 MOVLW B'01010000' ;new analog stuff for the 913, fosc/16 MOVWF ADCON1 ;=20 MOVLW B'00000001' ;setting up an0 as the only analog input MOVWF ANSEL ; SET PORT I/O ASSIGNMEBTS MOVLW B'11111111' ;setup all inputs on portA MOVWF TRISA ;setup trisa=20 MOVLW B'00000111' ;RB3-7 as output 0&1&2 as inputs MOVWF TRISB ;setup trisb MOVLW .0 ;Set RC<7:0> as outputs MOVWF TRISC ; movlw B'00000100' ;pull up on RB2 only movwf WPUB BCF STATUS,RP0 ;Bank 2 BSF STATUS,RP1 ; CLRF LCDCON ;Disable VLCD<3:1> BCF STATUS, RP1 ;back to bank1 bsf STATUS, RP0=20 MOVLW B'00000000' MOVWF OPTION_REG ; PORT B PULLUPS on BCF STATUS,RP0 ; SWITCH BACK TO BANK0 MOVLW B'10000001' ;right justify, A/D TO "ON" MOVWF ADCON0 ; AND CHANNEL 0 (RA0) SELECTED =20 ;;******************** ;; Setting up PWM=20 ;;******************** BSF STATUS,RP0 ; SWITCH TO BANK 1 BCF STATUS,RP0 MOVLW .254 ; SETUP THE PWM FOR LONGEST POSSIBLE PERIOD=20 MOVWF PR2=20 BCF STATUS,RP0 ; SWITCH BACK TO BANK 0 ;CLRF CCPR1L movlw .255 ;debug mode only movwf CCPR1L BSF STATUS, RP0 ;back to bank 1=20 bcf TRISC, 5=20 MOVLW B'00000010' MOVWF T2CON ; SET UP TMR 2 (16:1 PRESCALER) BSF T2CON,2 ; ENABLE TMR 2 (MUST BE DONE IN A SEPARATE STATEMENT) BCF STATUS, RP0 ;and back to bank 0 MOVLW B'00001100' ; SET CCP1CON FOR PWM MODE AND MOVWF CCP1CON ; SET DUTY CYCLE FOR ZERO UNTIL 1ST A/D READING -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist