View Full Version : Timing Codes
Ryan Cumings
29-01-2004, 17:54
Does anyone know where to find the timing codes for the PIC?
Astronouth7303
29-01-2004, 17:56
How so? you can have one of the timer interupts increment a variable, or count iterations throught the main loop.
Ryan Cumings
29-01-2004, 18:02
Well I'm not looking to see how fast an algorithm would run. I'm looking to see how many cycles different instructions would take. Like an opcode reference.
Astronouth7303
29-01-2004, 18:22
I'm not sure I understand entirely, but by the sound of it, I'd suggest using a timer interupt.
Rickertsen2
29-01-2004, 18:47
Well there are 2 ways to do this.
1.) View the disassmebly code output from the compiler and trace the program flow.
2.)Set up a timer that rums in the background and times different operations.
Btw.. although the processor is 40mhz, one operation takes 4 clock cycles. Hence 10mips.
SeanCassidy
29-01-2004, 20:53
This helped me a lot, it allows you two write two different but very acurate timers.
http://www.innovationfirst.com/FIRSTRobotics/pdfs/Timers_White_Paper_2004-Jan-14.pdf
Ryan Cumings
29-01-2004, 21:02
Not quite what I was looking for. There are some x86 opcode references that have an estimate for the number of cycles it takes to execute an instruction (This would be dependant on the maker of your cpu). I was wondering if anyone has seen something like this for the PIC18F8520?
Rickertsen2
29-01-2004, 21:04
Not quite what I was looking for. There are some x86 opcode references that have an estimate for the number of cycles it takes to execute an instruction (This would be dependant on the maker of your cpu). I was wondering if anyone has seen something like this for the PIC18F8520?
they all take 4 cycles except i think retfie(i think i'ts retfie. you better double check this). See the datasheet.
deltacoder1020
29-01-2004, 21:33
It's not for the same model of PIC, but here is one document that lists the cycle times for various instructions - many of them may be the same (there's other stuff in the file too, scroll down):
http://www.microchip.com/download/lit/prdbroch/40170b.pdf
Rickertsen2
29-01-2004, 21:43
It's not for the same model of PIC, but here is one document that lists the cycle times for various instructions - many of them may be the same (there's other stuff in the file too, scroll down):
http://www.microchip.com/download/lit/prdbroch/40170b.pdf
the cycles listed there should be the same. the 18x series has some additional instructions though. What they call 1 cycle refers to 1 instruction cycle not one clock cycle.
Ryan Cumings
29-01-2004, 21:44
Thank you deltacoder, this was exactly what I was looking for (or pretty close). Finally tommorow I'll be off academic probation and back doing my passion =D
deltacoder1020
29-01-2004, 22:26
amazing what Google can find ;) good luck on your programming - we just finished our drive base today, so now I get to start having some fun. (My team leader would probably shudder if he heard me saying that.)
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.