Hi,
OK, I don't know from where I got that you had 72 steps in the lookup table. Now I know it's 90. If can live with fewer steps you'll be able to increase the output frequency.
I'm pretty sure you're simply running out of time. I made some quick tests here but in order to do so I had to change your code a little bit (don't have 4431 handy to test on). So I'm not sure exactly how much we can depend on these.
I'm using a 18F4520 @20Mhz.
The interrupt routine itself runs in about 70us, the overhead introduced by the interrupt system (DT-ints) is from previous tests I've done about 29us (again at 20Mhz) at interrupt entry and I would guess about the same on exit. This means each interrupt takes a total of ~130us.
1/0.000130 = 7700Hz
I've verified this by specifying InterruptFrequency of 7700Hz and it works, I get 7700 Hz with nice, steady pulses. If I specify 8500Hz I can see on the scope that the trace is starting to get jittery indicating that it's starting to overrun it self, missing pulses so think I'm pretty close to the absolute max at 7500-8000Hz.
Now, in theory, since you're running at 40MHz you should be able to get twice that, ~15kHz but apparently you're not. Can you set a pin high at the beginning of the interrupt service routine and set it low just before @INT_RETURN, then measure how long that output is high. That will tell you the execution time of the actual handler (where I got 70us).
Are you sure that the PIC is running at 40Mhz? Simply specifying DEFINE OSC40 doesn't make it run at 40MHZ, you need to enable the PLL thru the CONFIG bits as well.
/Henrik.
Bookmarks