Hi,
Alain already wrote this in the very first reply but it seems to have gone unnoticed. When using the CCP-module in the PIC to generate a PWM output (which is what the HPWM command does) there's lower limit on the frequency depending on the frequency of the PICs oscillator. For a 14-bit PIC (which the 16F88 is) running at 8MHz that lower limit is 489Hz. All according to the manual. You're trying to set the frequency to 150Hz when it can't go lower than 489Hz, it's probably overflowing.
And, which Alain also wrote, in the original code you had the Frequency variable declared as a BYTE. That won't work since the lowest possible value you can assign to that variable when the PIC is running at 8MHz is again 489 so you must declare Frequency as a WORD.
Finally, I seem to remember something about HPWM not being suitable for continous update like this, probably because it sets up the CCP module for PWM each and every time but I'm not sure. I know that Darrel (of course...) wrote a routine better suited for that - and that was able to use the full 10bit resolution when available. Search for HPWM10 or something like that.
/Henrik.
Bookmarks