I am comparing the speed of port writes on the Infineon XC167 to the ARM LPC2294 since I need to do some rapid bit-bashing to my peripherals. The C166 compiler generates one line of code that executes in one cycle, while the ARM compiler generates three lines to set an immediate value into the port. This appears to take about 10 machine cycles. Is the ARM that much worse at I/O or is the compiler just doing a poor job of utilizing the instruction set of the ARM?
Which ARM compiler - GNU or Keil? Version?
The Keil version
You didn't say what instructions they were, though I think I can guess, and I suspect they are indeed minimal. The ARM architecture doesn't specify a separate I/O space -- everything is memory- mapped, so: 1) There are no dedicated (fast-path) I/O instructions -- load and store is all you get. 2) All I/O goes out over an external bus; this may or may not cost much, but it's (architecturally) there. Moreover, immediate constants are, um, a "challenge": Outside of a small range, constants can't be loaded directly, rather they must be constructed arithmetically. Some constant values are more amenable to this than others, and this can take 1 or 2 (even 3?) instructions. So it could be said that the ARM isn't very good at I/O in particular, and your compiler is (at 3 instructions) probably doing as well as it can. That said, a) If what you're doing is "bit-bashing", you'll probably find that the marginal cost of additional I/Os is much smaller than that for the first. b) What the ARM people did somehow (I don't know how -- I think it's magic (:-))) is to design a core which can be implemented to run at high speed on low power. Thus, what you may find is that for a given Clock Speed the ARM loses the "race", but that for a given Power Usage, the ARM wins.
Thanks for your observations. We have found that we can toggle I/O lines at about 8MHz by running the peripheral bus at full speed (VPBDIV = 1;) and using inline assembly to minimize the number of instructions. Not blazingly fast considering the 60MHz clock, but probably good enough.