Hi,
The reason it runs slow is due to the interrupt driven PWM routines. You have a PWM frequency of 200Hz and a resolution of 256 steps, this results in an interrupt frequency of 51200Hz.
According to Darrels page (if I'm on the right one) each "PWM-channel" needs 20 instructions - in your case 51200 * 20 * 2 = 2,048,000 instructions per second, just for running the 2 PWM channels. At 20MHz there's 5,000,000 instructions per second to play with which means that 40% of the processors time is spent running the PWM.
You tell PBP that you're running at 20MHz but then the assembly interrupts silently eats away 40%.
In this case each and every Hz you decrease the PWM frequency will give more time to the actual PBP program, if 100Hz is "all" you need then don't try running it at 200Hz. But again, it doesn't seem to be the timing per se that makes it NOT work since it using different ports for the PWM and I2C works.
/Henrik.
Bookmarks