Hello Thanks for much of your comments regarding the PWM. I have finally found the problem with changing of the PWM frequency. I believe it to be a device flaw. However please look at both code examples below and you will see what I am talking about. Both are logically correct, but only one works. Any ideas???? The problem did lay in the changing of the timer2 prescale value. The code that does not work, but is logically correct for setting the prescale for timer2: SetTrickel: 1 ;1, set the period register. 2 MOVFF TRICKEL_FREQ_PERIOD,PR2 3 ;2. Write the duty cycle 4 MOVFF TRICKEL_DUTY_H,CCPR1L 5 MOVLW B'11001111' 6 ANDWF CCP1CON,W,A 7 IORWF TRICKEL_DUTY_L,W,BANKED 8 MOVWF CCP1CON,A 9 ;3. Set prescale 10 MOVLW B'00000011' 11 ANDLW 0X03 ;Prescale bit for 16 12 IORLW 0xfc 13 ANDWF T2CON,F,A 14 ; BCF T2CON,T2CKPS0,A 15 ; BSF T2CON,T2CKPS1,A 16 ;4. Turn timer 2 on and configure for PWM mode. 17 BSF T2CON,TMR2ON,A 18 RETURN The above logic (Lines 9-13) set the prescale using a bit masking method as follows 10. Sets bits 0 and 1 high into working register. 11. Masks out bits 2-7. Normally this would be done to a register variable, but I have to test with a constant to ensure that there was in fact a flaw. 12. Adds masking bits 2-7 to the working register while keeping the previous lower bits 0 and 1 content. 13. Takes the masking bits in working register and removes all unwanted 1's from T2CON. This logic is a correct method, but does not work. Now below is another method which does work. SetTrickel: 1 ;1, set the period register. 2 MOVFF TRICKEL_FREQ_PERIOD,PR2 3 ;2. Write the duty cycle 4 MOVFF TRICKEL_DUTY_H,CCPR1L 5 MOVLW B'11001111' 6 ANDWF CCP1CON,W,A 7 IORWF TRICKEL_DUTY_L,W,BANKED 8 MOVWF CCP1CON,A 9 ;3. Set prescale 10 ;MOVLW B'00000011' 11 ;ANDLW 0X03 ;Prescale bit for 16 12 ;IORLW 0xfc 13 ;ANDWF T2CON,F,A 14 BCF T2CON,T2CKPS0,A 15 BSF T2CON,T2CKPS1,A 16 ;4. Turn timer 2 on and configure for PWM mode. 17 BSF T2CON,TMR2ON,A 18 RETURN Now this above code comments out lines 10-13 and uncomments lines 14 and 15. Line 14 clears bit 0 of T2CON. Line 15 Sets bit 1 of T2CON. These two bits are hex equivalent of line 11's result of 0x03, correct! Also bits 2-7 of T2CON remain unchanged, which is the desired effect of the bit masking logic in the first example. Now, why is it that using bit instructions makes the entire code work, but on the other hand using bit masking logic and ANDing the contents of T2CON with the mask does not work. This is either a flaw or I have missed something all together. Any clues. You have to agree with my sanity here. I was going crazy over this logic. I know that the masking logic is correct. So why does only bit twiddling work??????? One further comment, in example 1, which did not work, I substituted line13 with the following two lines of code in the hopes that this had something to due with it: 13. ANDWF T2CON,W,A ;Make the result go back into the working register. 13a. MOVWF T2CON,A ;Move the working into register T2CON. Regards, James -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body