Timing Codes

Does anyone know where to find the timing codes for the PIC?

How so? you can have one of the timer interupts increment a variable, or count iterations throught the main loop.

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.

I’m not sure I understand entirely, but by the sound of it, I’d suggest using a timer interupt.

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.

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

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.

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.

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

amazing what Google can find :wink: 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.)