Henrik,
Yes, I had the numbers backwards. I meant us not Mhz. Sorry. Thank you once again for the timing overview. It is all starting to fit together--slowly. The application I am planning is not especially time critical, but I will have a lot going on. I will have 10 Analog inputs and 10 servo outputs. Along with about a half dozen other inputs that need to be processed. The servo alone would take up the full time, except I am hoping to use interrupts to stop the pulses at the appropriate time, as the servos have to be refreshed every 20 MS.
Richard, Thank you for clarifying the timing of instructions.
Larry
Announcement
Collapse
No announcement yet.
Confusion between oscillator speed and instruction clock speed
Collapse
X
-
Hi,
With the osc set to 32 Mhz I see a pulse of 0.5 Mhz on a oscilloscope. With the osc set to 16 Mhz I see a pulse of 1.0 Mhz.
Actually, a program consisting of nothing other thanCode:Main: High PortA.0 Low PortA.0 Goto Main
Code:_Main bsf PORTA, 000h movlb (((PORTA) + 80h)) >> 7 bcf ((PORTA) + 80h), 000h movlb (PORTA) >> 7 bcf PORTA, 000h movlb (((PORTA) + 80h)) >> 7 bcf ((PORTA) + 80h), 000h movlb 0 bra _Main
Now, if we do this instead:Code:TRISA.0 = 0 Main: PortA.0 = 1 PortA.0 = 0 Goto Main
Code:movlb (TRISA) >> 7 bcf TRISA, 000h movlb 0 _Main bsf PORTA, 000h bcf PORTA, 000h bra _Main
Larry, this example is EXACTLY what I've tried to explain in your previous threads. Ie that the high level commands are convenient but not always very effecient. Since HIGH/LOW "automatically" makes the pin an output it has to clear the TRIS bit right? So it does and it does it EVERY time you use HIGH/LOW because it doesn't know if something has changed the TRIS-bit.
(When you're doing things like this you tend to get into RMW-issues but that's another topic).
If you're not shooting for as much performance as possible you don't have to worry about but you should know about it, this illustrates the point perfectly.
But again, if what you wrote earlier is correct and you're getting double the output frequency when you're reducing the clock frequency somehting else is wrong.
/Henrik.
Leave a comment:
-
Low PortA.0
Code:BANKSEL trisa bcf trisa ,0 BANKSEL porta bcf porta ,0
High PortA.0Code:BANKSEL trisa bcf trisa ,0 BANKSEL porta bsf porta ,0
using high / low is not the quickest way to toggle pins
Leave a comment:
-
Confusion between oscillator speed and instruction clock speed
Confusion between oscillator speed and instruction clock speed
Using the ME Labs Trainer w/PBP with a PIC 16F1937, I am confused between the speed of the oscillator and the speed of the instruction clock.
I am monitoring the output of portA.0 with an oscilloscope. My program just says Low PortA.0 then High PortA.0 a number of times. With the osc set to 32 Mhz I see a pulse of 0.5 Mhz on a oscilloscope. With the osc set to 16 Mhz I see a pulse of 1.0 Mhz.
What is the relationship between the clock (osc) speed and the instruction clock speed?
Thanks
Larry CardoTags: None
Leave a comment: