Re: Maximum speed, all ports as I/O
- From: Neil <NeilKurzm@xxxxxxxxxxxxxxxx>
- Date: Fri, 07 Mar 2008 22:44:49 -0500
Tomás Ó hÉilidhe wrote:
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)
It is set to 4Mhz because that is what the data *** says is the default. You can play with OSCTUNE. OSCCON is the one you want you can set set the chip to 8Mhz. The internal OSC has a divider control That is how it gets 4Mhz ( or 2 or 1 or .5mhz) "INTIO" as I recall gives you Internal OSC with IO. There is an Oscillator section in the Data ***.
Since your config looks like Hi-tech C Not that any delay loop whitten in C may change with different versions of the compiler. Either faster or slower. Or, they may not.
.
- Follow-Ups:
- Re: Maximum speed, all ports as I/O
- From: Tomás Ó hÉilidhe
- Re: Maximum speed, all ports as I/O
- References:
- Maximum speed, all ports as I/O
- From: Tomás Ó hÉilidhe
- Re: Maximum speed, all ports as I/O
- From: John Speth
- Re: Maximum speed, all ports as I/O
- From: Thad Smith
- Re: Maximum speed, all ports as I/O
- From: Tomás Ó hÉilidhe
- Maximum speed, all ports as I/O
- Prev by Date: Re: Please help me.How could this happen?
- Next by Date: Re: Maximum speed, all ports as I/O
- Previous by thread: Re: Maximum speed, all ports as I/O
- Next by thread: Re: Maximum speed, all ports as I/O
- Index(es):