Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

External oscillator on a PIC16F628A MCU question…

Status
Not open for further replies.

mbu

New Member
I’m a little lost; maybe some would take the time to help me.

I have a circuit that uses an external 10Mhz crystal oscillator on a PIC16F628 MCU. So if I want 1 second of real clock time do I count 10,000,000 oscillations or is it some fraction of this?
 
Obviously, at 10 million oscillations per second, you count 10 million of them. If I were doing it, I would use PICBASIC and would have to calculate the difference between 4 mHz oscillations and 10 mHz.
 
Oops! guess I should have worded it like this:

On a PIC timer0 how many ticks/second will a 10Mhz oscillator have? Since the MCU takes 4 cycles an instruction, I was wondering if I need to divide the 10Mhz oscillator by 4 to obtain the timer0 ticks per second.
 
Some helpful tools to help you generate PIC Delays...



PDel ver 1.1 Zip file. size 91.3 Kb
 
The speed in which a PIC will operate is a division of 4 of the crystal, and TMR0 will increment each instruction cycle depending on the pre-scaler, and a TMR0 overflow interrupt will occur every time TMR0 overflows from 255 to 0.

So a 10Mhz crystal will have the PIC operating at 2.5Mhz. This means that every second, 2.5 million instructions are executed.

The TMR0 interrupt (with a prescaler of 1:2) will occur every 512 cycles, so 2.5Mhz / 512 = 4882.8125 interrupts a second (or 0.0002048 seconds = 204.8uS)

If you change the Pre-Scaler too 1:4 then an interrupt will occur once every 1024 Cycles, so 2.5Mhz / 1024 = 2441.40625 interrupts a second (or 0.0004096 seconds = 409.6uS)
 
Status
Not open for further replies.

Latest threads

Back
Top