CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Question on PIC's instruction cycle time

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
valemike
Guest







Question on PIC's instruction cycle time
PostPosted: Wed Feb 09, 2005 11:39 am     Reply with quote

I'm using an 8MHz crystal.

Is my instruction time 4/800000 = 500 ns?
Or is it 1/8000000 = 125 ns?

What does the 4X PLL do for me? Gives me 1 / (4 x 8000000) = 31ns per instruction?

I've tried deciphering the timing diagrams on the datasheet, but am not quite sure.

Reason why i ask is that i'm dealing with a motor whose encoder feeds into RB0 at rates of up to 546 uS. I'll be stuck in ISRs all the time then! (Yeah i know, i should have fed the encoders to externally clock TOCKI and TOCKO, but too late - hardware is done).

Thanks,
Mike
Chas
Guest







PostPosted: Wed Feb 09, 2005 11:55 am     Reply with quote

The instruction cycle is 4 clocks long. Therefore, at 8MHz, each instruction will take 500ns. At 546us per interrupt, you still can execute more than 1000 instructions between interrupts. If you enable the 4X PLL you would quadruple that number.

If you don't have any other interrupts and have a bit of courage, you might look at using the global interrupt. I have used it for a clock tick interrupt via timer 1 and it requires very few instructions to get into the interrupt and back out. Search this forum for other threads.
valemike
Guest







PostPosted: Wed Feb 09, 2005 12:08 pm     Reply with quote

Chas wrote:
The instruction cycle is 4 clocks long. Therefore, at 8MHz, each instruction will take 500ns. At 546us per interrupt, you still can execute more than 1000 instructions between interrupts. If you enable the 4X PLL you would quadruple that number.


Thanks Chas. So let's see, the 4X PLL then would cancel out the /4, so in 4XPLL mode, i get: 1/8MHz = 125ns per instruction?

Okay cool, thanks for the re-assurance on the earlier post!
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Question on PIC's instruction cycle time
PostPosted: Wed Feb 09, 2005 12:09 pm     Reply with quote

valemike wrote:
I'm using an 8MHz crystal.

Is my instruction time 4/800000 = 500 ns?
Or is it 1/8000000 = 125 ns?

What does the 4X PLL do for me? Gives me 1 / (4 x 8000000) = 31ns per instruction?

I've tried deciphering the timing diagrams on the datasheet, but am not quite sure.

Reason why i ask is that i'm dealing with a motor whose encoder feeds into RB0 at rates of up to 546 uS. I'll be stuck in ISRs all the time then! (Yeah i know, i should have fed the encoders to externally clock TOCKI and TOCKO, but too late - hardware is done).

Thanks,
Mike

8MHz - 500ns
The 4X gives you a 32MHz clock which is 125ns instruction cycle time.
valemike
Guest







PostPosted: Wed Feb 09, 2005 12:26 pm     Reply with quote

Thanks for verifying the math Mark! I'm relieved to find out that my hardware is still feasible.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 09, 2005 1:27 pm     Reply with quote

I didn't see where you said specifically WHICH PIC you are using.

Some of the PIC18Fs (I'm assuming you are using those since you mention the x4 PLL) have a maximum clock speed of 25MHz while others run to 40MHz. It depends on the part and in some cases in what mode you run the part.

If your part has a maximum of 25MHz clock, then you cannot use an 8MHz plus x4 PLL option.

Check the data sheet first.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 09, 2005 3:13 pm     Reply with quote

Without looking at every pic18 datasheet, the max clock frequency is 25MHz. If you want 40MHz then you have to use the 4X with a 10MHz clock. I don't know of any 18's that will only run at 25MHz unless there is a problem and an errata indicates the fix is to run at a slower speed.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 09, 2005 4:06 pm     Reply with quote

A good example is the PIC18F6620/6720/8620/8720 which has a top speed of 25MHz in microcontroller mode and 16MHz in microprocessor mode. So as I understand the chip, you can put a 6MHz and use the x4 PLL to get to 24MHz for example, but you can't put a 10MHz out there and expect the chip to run as a 40MHz part. Find a 6.25MHz crystal and you can boost yourself upto the full 25MHz.

Check the "External Clock Timing Requirements" table in the Electrical Characteristics sections of the datasheets, YMMV.

In technical terms, the '8720 has a zillion I/O and oodles of memory and can be run in either the single chip or multi-chip (microprocessor) mode.

On the other hand, the new and improved '8722 (should just be coming on-line at the usual distributor sources) is supposed to run out to 40MHz.

And a few of the PIC18s are listed as 48MHz parts.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
valemike
Guest







PostPosted: Thu Feb 10, 2005 10:31 am     Reply with quote

It's the 18F448 i'm using. It says in the manual that it can go to 40Mhz.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Thu Feb 10, 2005 11:02 am     Reply with quote

valemike wrote:
It's the 18F448 i'm using. It says in the manual that it can go to 40Mhz.


In this case, assuming you are using the industrial temp range grade and not the extended temp range grade, and your Vdd is >4.2V (ie not the LF part), Mark's advice above is correct. The part can be run at 40MHz if you use an external oscillator or if you use a 10MHz xtal and the HS+PLL option.

If you were to swtich to the LF part, the maximum speed is given by the function Shocked
FMAX = (16.36 MHz/V) (VDDAPPMIN � 2.0V) + 4 MHz
for 2.0V <= Vdd < 4.2V

*** Philosophize Mode On ***

Anyway, there has been a lot of dicussion the last few days about maximum operating speeds. All this stuff is in the datasheets. I tend to RTFM people but it is really for their own good. It is one thing to be told and answer and another thing to be shown how to find the answer. It may take a little bit longer to show how to find the answer but it is my opinion that the information "sticks" better in the target's mind.

Learning to read datasheets seems to be a low priority for most "beginners" and "intermediate" users. Always look past page 1 when checking specs because page 1 seems to be written by the marketing department. The real answers are back in the AC and DC specifications which Microchip tends to put as an appendix.

Datasheet interpretation is a very valuable skill but unfortunately is only learned by slogging through everthing and each manufacturer does it a little bit differently! Twisted Evil

*** Philosophize Mode Off ***
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Thu Feb 10, 2005 11:21 am     Reply with quote

Amen to that, Rob.

I'm presently teaching a pic programming course to two groups of technologists. Roughly 95% of them are now at the point where I can give them a task that they'll have to get the pic to perform, and I never have to help them. They simply call me over when it's done. If there's anything they don't know, they look it up themselves. That's the group that I'd like to hire from, if I was an employer.

The rest......ugh. You ever heard the phrase "you can lead a horse to water, but drowning one is a real b***h." It doesn't matter how many times I try to point them in the right direction, and gently suggest that they read the data sheet for the part they have to interface to, but.....I guess I have to take solace in the fact that most of them get it.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group