CFV1 execution times

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CFV1 execution times

676 Views
Bloodhound
Contributor I

Hi All,

 

Is there a table showing the clock cycle execution times for each CFV1 instruction?

 

Second to that, something I am working on at the moment needs to change port states from inputs to outputs pretty fast (well, not like 1,000's of times per second, maybe 10), is there is limitations to how fast the ports can change from inputs to outputs and back?

 

Thanks,

Ross

Labels (1)
0 Kudos
2 Replies

380 Views
armistej
Contributor III

Ross

 

Have a look at the specific Reference Manual for the CPU you're going to use.

 

If, for example, I refer to the MCF51CN128 Reference Manual

 

http://cache.freescale.com/files/32bit/doc/ref_manual/MCF51CN128RM.pdf?fpsp=1

 

then, in section 7.3.4  is a whole discussion of Instruction Execution Timing.

 

It's pretty involved, depending on the addressing mode you're using for each instruction operand.  Definitely a non-trivial task if you're trying to figure out the timing for any significant section of code.   The older 68HC05 assembler (going back 10 years !) used to give a nice listing showing execution times for each line of machine code, but I've never discovered the same thing with CodeWarrior.  Sigh ! The definition of "progress' is always a relative term !

 

Sometimes it's easiest to use some spare I/O ports to drive a few oscilloscope channels and look at the execution times for your code that way.

 

With regard to switching ports from inputs to outputs, I would expect that it's only limited by the time to change the value stored in data direction register associated with the port.  This should simply be a function of clock speed and execution time for whatever instruction your compiler generates to do this.  I can't recall seeing anything in the Reference Manual which says this is limited by some other factor.  10 times per second should be a walk in the park.  Remember, if you were using an external data bus e.g. the Mini-FlexBus, it would be switching the bus data lines must faster than you are !

 

Good luck, and let us know how you're doing !

J

0 Kudos

380 Views
TomE
Specialist II

Benchmark of MCF5329 running at 240MHz:

 

1 - Loop of "MCF_GPIO_PODR_TIMER = 0;"

2 - Loop of "MCF_GPIO_PODR_TIMER |= 1;"

3 - Loop of "MCF_GPIO_PDDR_TIMER = 0;"

4 - Loop of "MCF_GPIO_PDDR_TIMER |= 1;"

 

1 - 1000 writes to PODR took 76us
2 - 1000 RMW to PODR took 141us
3 - 1000 writes to PDDR took 75us
4 - 1000 RMW to PDDR took 141us

 

So a write to a port register takes about 76ns or about 18 CPU clocks and a "port |= bit" read-modify-write takes about 33 clocks. Plus or minus a lot for the loop overhead in my test code.

 

To answer the origina question, you can change the port direction in 76ns. So this looks to be very good on the Coldfire. It could be a lot worse. I've worked on other CPUs that take over 200 CPU clocks to write to a GPIO port bit.

 

 

0 Kudos