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.

How to calculate the timing for each instruction using PIC MCU

Status
Not open for further replies.
Right, I've already understood that (but as I said, is only for curiosity), maybe I'm not exaplaining myself.

What I want to know, is for what that is usefull. In what situation we need to apply the PLL?

Like I said, essentially if you want to run at 40MHz, other uses are secondary - such as lowering power consumption by turning it OFF.
 
Ok then. So running at 40Mhz, the instructions will run more faster, and the PIC will work faster. That is the purpose..

Thnks.

Best regards
 
Running a graphic display is an example where you may want to use a faster speed..
But if you are just flashing a few LEDs, there is no point in using PLL, as you wouldn't see it! :)
 
So, for example: When I look at an LCD with menus and the option to scroll, all that stuff are running at 40MHz? That is so fast that when cannot realise that the image look like pictures, like frames.. well I can't explain :p I hope you understand
 
So, for example: When I look at an LCD with menus and the option to scroll, all that stuff are running at 40MHz? That is so fast that when cannot realise that the image look like pictures, like frames.. well I can't explain :p I hope you understand

I don't think you really understand PIC's very well yet, but keep at it and all will make sense in no time at all.
The best is to start with some tutorials and a breadboard... the quickest way to learn is doing it hands-on.
 
Hi,

May I know how to calculate how much time does this Timer0 is set based on the 32MHz internal clock with PLL that I have set.

or

May I know where to find the formula to do this calculation?

OpenTimer0( TIMER_INT_ON & T0_8BIT & T0_SOURCE_INT & T0_PS_1_64 );
 
I would guess that it's 1/(32,000,000/4/64/256) = 2.048mS

That is Osc/4 gets fed into the timer prescaler (/64) and then the timer takes 256 counts to roll over.

Mike.
 
I would guess that it's 1/(32,000,000/4/64/256) = 2.048mS

That is Osc/4 gets fed into the timer prescaler (/64) and then the timer takes 256 counts to roll over.

Mike.

Oh... may i know why must the timer takes 256 counts to roll over?
It there any reference to recommend?

Thanks for your help. :)
 
OOH! Variable speed! That's like the Intel Speed Step technology that makes my 1.6GHz Pentium-M so seemingly speedy!

So, I have 12F683, 16F688, and 16F872, and figuring the latter is the biggest newest, I searched its PDF for PLL, finding none, went for "phase" and found no reference related ..

what chips support this variable speed? Just for curiosity. I know I could change existing ones to be slower (and I thank ye all for the thoughts of going even 32KHz for some of my "waiting around for something slow" projects). Even a ... say ... wireless Data Logger could lounge around in the KHz range and crank up to 4 or 8MHz to do say wireless or maybe USB or IR sends... cool. But just curious about "really cranking them up", too.
 
Oh... may i know why must the timer takes 256 counts to roll over?

The timer takes 256 to roll over because it is 8 bits. If you change to timer 2 then you can set the value that it should roll over at in register PR2. Have a read of the timer 2 section in the data sheet.

Mike.
 
OOH! Variable speed!

what chips support this variable speed? Just for curiosity.

Some of the 18 series chips have the PLL. The one I believe the OP is using is the 18F2520 which can use the internal oscillator in combination with the PLL to manage 32MHz. The 18F2550 has USB support and an internal speed of 48MHz. With both of these chips the instruction time is ¼ of the oscillator frequency, so a 32MHz chip will execute 8MIPS.

Mike.
 
The timer takes 256 to roll over because it is 8 bits. If you change to timer 2 then you can set the value that it should roll over at in register PR2. Have a read of the timer 2 section in the data sheet.

Mike.

Oh... so if i set to 16bits than it will take 65536 to roll over?

OpenTimer0( TIMER_INT_ON & T0_16BIT & T0_SOURCE_INT & T0_PS_1_64 );

The time for this timer setting will be 1/(32,000,000/4/64/65536) = 0.524288S

Am I right ? :)

Another question is what is the purpose of dividing the above formula by 4?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top