> Your kidding I assume.
My kidding what? You mean "you're kidding" I assume :smileyhappy:
Not kidding.
The CPU runs a 60MHz or 17us clock cycle, which is the instruction issue rate for executing NOPs. Correction, the TPF execution rate (NOPs take 3 clocks). To a first approximation, all bus cycles (instruction fetch, data read and write) take one clock cycle EXCEPT for successive stores which attract a two-cycle pipeline stall. And all reads (move from memory to register) which take 3 clocks instead of 2 for some reason.
The FLASH seems to be one-cycle-access, but there's a "factory option" of two cycles initial or something. I'd run my code from SRAM - I can trust its speed. At least this CPU doesn't have a cache to complicate the timing.
A 2,5MHz clock cycles in 400ns, with a 200ns high and 200ns low period. Or 12 TPFs for high and 12 TPFs for low. Or 4 "read instructions".
So when emulating an MDIO read cycle the software has to "see" the falling edge and drive the data bit way before the next rising edge, at least in half of the time. So "test, branch, write and loop back" in less than 6 clocks. I don't think so.
Apart from all the other problems, you can't assume the GPIO ports run at the same speed as the CPU. Sometimes they stall the CPU for multiple clocks on reads and writes. The MCF52 is probably fast. The MCF54 has been reported as slow. I've worked on an ARM cpu (PXA320) that took 400 CPU clocks to read or write an IO port.
Here's someone who's managed almost 2MHz as an MDIO Master on an MCF52233, but that is a very tight loop blindly generating clocks and data when it wants to send them and not syncing to someone else's clock:
https://community.freescale.com/message/52298#52298
Being "always ready" to receive one of these messages is a lot harder than sending them.
> Just interrupt on the rising edge, and read the data input.
I assume you mean "interrupt on the 2.5MHz clock".
A normally coded interrupt service routine is:
1 - Take the interrupt,
2 - Push 16 registers onto the stack
3 - Call the service routine
4 - Pop the 16 registers from the stack
5 - Return.
The Register push and pop is going to take 34 clock cycles. Of course this can be coded in special-case assembly, only using a subset of the registers, but that's really not going to fly. There's only 12 clocks from interrupt-to-read! As well, you don't know WHEN the interrupt happened (in time) and which clock edge you'd be up to so as to decode the Read or Write part of the instruction.
Which is why I said "capture the edge with a timer and slow the clock rate right down".
This device might be doing something else. It might be servicing other interrupts. Which causes bad interrupt latency problems. Which can probably be overcome with multi-level interrupts, as long as nothing else in the entire codebase is disabling interrupts to protect a data structure anywhere.
Tom