> If we run only NOPs, the 5328 system is running faster than 5272, but not in the right ratio (48MHz vs 240MHz),
That's the ratio of the memory clocks. The MCF5328 has an 80MHz memory bus and I'd guess the 5272 is running at 48MHz.
The CPU can issue instructions at 240MHz. But only from SRAM or the cache.
When the cache is enabled, it reads a whole line (16 bytes) of data from the SDRAM to the cache line.
With 32-bit SDRAM that takes 10 memory clocks. In your case (16 bits wide) that would take 14 memory clocks. That is 42 CPU clocks to get 8 16-bit instructions or 4 32-bit instructions. That is a lot slower than the CPU can execute them, but the whole idea is to get your loops read into the cache, so only the first time is slow - the rest of the times are fast.
Without the cache, the CPU has to read EVERY instruction from the SDRAM. That will take at least 7 or 8 memory clocks.
Which is 21 or 24 CPU clocks. And if that instruction needs to read some data from memory that'll take another 21-24 clocks.
So by not running from cache your 240MHz CPU is running at 10MHz. A 20 year old 68000-based system could outrun it.
If you're happy with 20-30 year old performance, then leave the cache off. If you need it faster you MUST enable the cache.
Checking those figures, you're getting 100 NOPs in 8us. Do you know that a NOP takes 3 clocks and flushes the CPU execution pipes? The "proper NOP" for the MCF5328 is the "TPF" instruction. Check the manuals for this.
Anyway 100 in 8us is 80us/instruction or 12.5 million per second. That's one instruction per 6.4 memory clocks (19.2 CPU clocks). That means the instruction prefetcher is reading 32 bits every 12.8 memory clocks, or about what I'd expect.
If you stepped up to the MCF5328 to get extra speed you could have got a speedup of at least 5 on your old CPU by enabling the cache on it. You still can. In fact as the MCF5272 cache only caches instructions (and not data) it should be easier to turn it on without causing DMA problems. Are you sure you don't have it turned on already?
> once I turn on the cache, USB interface and touch panel stop working.
Everybody else has been dealing with this since caches were invented, which would be about 1960. :smileyhappy:
You should set up the CACR with cache set to "cache inhibited, precise" and then set up one ACR to map the SDRAM set to "Cacheable, write-through". That means that only the SDRAM is cached and not the I/O registers or your FLASH.
Set the "Enable Store Buffer" bit in the CACR. It speeds up stores (especially to the LCD memory).
Setting the cache to WRITETHROUGH (instead of COPYBACK) avoids most of the problems. You should be able to write to the LCD panel and have it work. In this mode you don't have to flush writes to the hardware, but you do have to invalidate buffers you're reading that the hardware has just written.
You'll either have to invalidate the cache before any reads of USB rings or buffers, or (a lot easier) put all the USB buffers in SRAM like we do. If you have to have data in SDRAM then copy it to and from a set of buffers in SRAM.
If your USB drivers are properly written they should have "hooks" for tis, or be written assuming SRAM buffers.
Make sure you put the CPU's STACK in SRAM. That way all the function local variables are in zero-wait-state memory.
Tom