Re: Maximum speed, all ports as I/O




Thanks for the replies.

Firstly, here's why I think my chip is running at 4 MHz: I downloaded
some delay routine code from the Microchip website. In the header of
the code, they give the following assurance: "You can trust these
routines - these delay routines were used successfully in a commercial
product with over 2 years of development and 7000 lines of code". In
order to use the code, you've to define a preprocessor directive
called PIC_CLK. I had to set this to 4000000 to get the timing right
(I tested it with a Piezo speaker).

Anyway, since the internal oscillator is 8 MHz, and since the CPU runs
at the clock rate, shouldn't I be able to get it to run at 8 MHz? If I
indeed *can* get it to run at 8 MHz, then would this be done in the
configuration flags, or would I do it in the code in main?

One thing I'm curious about: Since the microcontroller only has two
internal oscillators (one being the 8 MHz, and another being 31 kHz),
how could it be that I'm getting the chip to run at 4 MHz? I was
wondering if maybe the delay routine code assumed that an instruction
took 2 cycles (rather than one cycle)? I'll look into it.

I've also been reading about the OSCTUNE register, which I can use to
get a 12% boost on the 8 MHz oscillator. I think it has to be set a
runtime tho, (as opposed to in static storage like the configuration
flags):

int main(void)
{
OSCTUNE = 0b1111; /* Run the oscillator at maximum */

return 0;
}

(Yes I realise I'll have to tweak the dealy routines if I tweak the
clock)


.