2) I mean something simple like this:This should switch the dutycycle between '40' and '400' att 500ms intervals which should be clearly visible on the "scope". Make sure you can do that before you try to move the PWM stuff to the ISR. Since you now know that is interrupt is firing properly and you can control the frequency all you need is to to move it back into the ISR.Code:Main: Temp = 40 GOSUB UpdateDuty Pause 500 Temp = 400 GOSUB UpdateDuty Pause 500 GOTO Main UpdateDuty: CCP1CON.4 = Temp.0 ' bit 0 CCP1CON.5 = Temp.1 ' bit 1 CCPR1L = Temp>>2 'Bit 2-7 RETURN
You are making progress but the key is to take it slow and try to understand each step. When something doesn't work, solve one problem at a time and take it slow.
/Henrik.




Bookmarks