![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) | |
|
I'm trying to educate myself more on the nitty-gritty of PIC assembly programming. First, I gather there is some kind of 1:4 relationship between PIC clock cycles and the PIC's crystal frequency. Is that right, and would anyone care to expand on that?
Second, if I'm trying to be careful about the timing in my program, how can I know how many cycles any given instruction will require (sorry if that's in the datasheet - if it is, can you point me to it?). Has anybody made an easy table illustrating assembly commands (or are they called instructions?) and their respective clock cycle requirements, e.g.: Quote:
Tutorial 4 Last edited by Hank Fletcher; 7th June 2008 at 06:36 PM. |
||
|
|
|
|
|
(permalink) | |
|
Quote:
__________________
My YouTube Videos! My Favorite Stores: dipmicro Electronics SparkFun Electronics Futurlec BG Micro |
||
|
|
|
|
|
(permalink) |
|
Hello,
It takes four oscillator cycles to complete one instruction cycle. Look at the section of the data sheet about the instruction set. It will have detailed info about each instruction. It will also break down what the processor is doing during the individual oscillator cycles. Take ADDLW for example: It takes one instruction cycle to complete, 4 oscillator cycles. 1.) Decode instruction 2.) Read the literal 3.) Process Data 4.) Write result to W So if you run a 4MHz crystal, that means your period for one osc cycle is (1/4MHz) = 250 nS. Four of these makes one instruction cycle, 250 nS * 4 = 1000 nS = 1 uS. Read, read, and re-read the instruction set summary chapter of the datasheet until it makes more sense how the processor executes instructions. -Jacob |
|
|
|
|
|
|
(permalink) |
|
Thanks, both! I have a follow-up question:
On the higher-end PICs, the product comparison charts list the individual PIC ICs speed in MIPs as oppose to oscillator frequency. Does that mean "millions of instruction cycles per second," then, which might not necessarily translate to "millions of instructions per second," since certain instructions might take more than one instruction cycle to complete? Also, there doesn't seem to be any way to deduce the actual oscillator frequencies for those high-end PICs from the product comparison charts. If it's rated 40 MIPS, what frequency external oscillator would I have to get? 160MHz? |
|
|
|
|
|
|
(permalink) |
|
I think the higher end PICs have a built in PLL clock multiplier. You'd have to check the PDF for the actual maximum oscillator frequency.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a straight answer, har har." |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| 89c52 crystal frequency | gondu | Micro Controllers | 2 | 9th January 2008 06:39 PM |
| Crystal frequency | redart | Datasheet/Parts Requests | 4 | 10th May 2006 07:25 AM |
| HELP: Connecting 4MHz crystal clock to PIC | mr. mister | Micro Controllers | 3 | 21st April 2005 12:26 PM |
| Help with Crystal frequency generator | 7404 quad2 input | Electronic Projects Design/Ideas/Reviews | 2 | 10th December 2004 04:19 PM |
| Can I use a 24mhz or 19.968 mhz crystal clock oscillator ? | xpembedded | Micro Controllers | 1 | 9th June 2004 09:48 PM |