The same for TMR2REG and TRISBP, actualy... And this line : T2OVRFLW btfss PIR1,1 would be more readable as : T2OVRFLW btfss PIR1, TMR2IF And in this line : clrf PIR1,1 ;###STEP 8: Configure & Start PWM note that the ",1" is the "access bank bit", not TMR2IF. A "1" says you are using the bank according to the BSR, but on the 18F1220, there is only one bank so, well... *But*, I actualy *do* think you are trying to clear the TMR2IF flag here. Then it should be : bcf PIR1,1 ;###STEP 8: Configure & Start PWM or better : bcf PIR1, TMR2IF ;###STEP 8: Configure & Start PWM Always using symbolic constants instead of ",1" is one way to protect yourself from *some* simple errors... Jan-Erik. -----Original Message----- From: Jan-Erik Soderholm XA (TN/PAC) Sent: den 25 september 2003 01:25 To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC:] Using Full Bridge PWM Mode on 18F1220 What is CCPREG ? Some constant of your own ? What is it's value ? Jan-Erik. -----Original Message----- From: gtyler [mailto:gtyler@DRUMMOND.ORG.ZA] Sent: den 24 september 2003 23:53 To: PICLIST@MITVMA.MIT.EDU Subject: [PIC:] Using Full Bridge PWM Mode on 18F1220 Hi I'm having problems getting the PWM to work in Full Bridge mode I want to use all four pins that this mode produces, but when simulating it in MPLAB SIM the PWM works in its normal mode (ie. only RB3 has PWM pulses on it instead of RB2 or RB3 and RB6 or RB7 being high during this time) I followed the instructions in the data sheets. If it will help here is a simplified version of my program(with irrelevant bits removed) I have labelled it according to the steps that are used in the 18C1220 data sheet movlw b'11111111' ;###STEP 1:Configure PWM Pins as inputs movwf TRISB movlw d'255' ;###STEP 2: Set PWM Period movwf PR2 movlw CCPREG ;###STEP 3: Set ECCP Mode to Full Bridge movwf CCP1CON movlw d'2' movwf CCPR1L ;###STEP 4: Set PWM Duty Cycle Note: Steps 5-7 are to do with automatic shutdown and other things like that so I figure it is okay to leave it out. clrf PIR1,1 ;###STEP 8: Configure & Start PWM movlw TMR2REG movwf T2CON T2OVRFLW btfss PIR1,1 goto T2OVRFLW ;###STEP 9: Wait for TMR2 Overflow and change PWM ports to outputs movlw TRISPB movwf TRISB I hope this is understandable :) Thanks Chris -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads