Excellent. There's only one more thing you can do to really clinch this one.
> I recommended that you DISASSEMBLE the code that you wrote.
I've got another question. When you successfully write to that register, does the "CMD" bit auto-clear? It isn't documented to, but I'm suspecting that it should.
The Debugger should show you the actual code very easily. I'd be interested to see if it is generating byte-wide writes or whether it is performing full 32-bit reads and writes. Could you check that please?
There's a trap with debuggers. Often when you ask them to read or write memory, they'll do it a BYTE at a time rather than doing 16-bit or 32-bit accesses. That makes the debugger code easier. This means you can sometimes try to write a 32-bit-write-only I/O register and have it not work at all. That can waste a lot of time until you work out what's happening. I'm not saying this is happening to you, just that it is one of the things to watch out for.
Anyway, I think you may have found a problem, not just with this (16 year old) manual, but with lots of them. Welcome to the club.
Firstly I was wondering why you're writing such weird code to set up that register. Nobody does it that way, none of the bootstraps do that, and NXP's sample code doesn't do that either. So why are you setting this register a few bits at a time?
Probably because that's EXACTLY what the Reference Manual (in fact all the related Reference Manuals) tell you to do:
18.7.3 SDRAM Mode/Extended Mode Register (SDMR)
See Section 18.5.2, “Power-Up Initialization”
18.5.2.1 SDR Initialization
7. Initialize the SDRAM’s mode register using the LMR command.
See Section 18.5.1.5, “Load Mode/Extended Mode Register
Command (LMR, LEMR)” for more instruction on issuing an
LMR command.
18.5.1.5 Load Mode/Extended Mode Register Command (LMR, LEMR)
The following steps should be used to write the mode register
and extended mode register:
1. Set the SDCR[MODE_EN] bit.
2. Write the SDMR[BA] bits to select the mode register.
3. Write the desired mode register value to the SDMR[ADDR].
Don’t overwrite the SDMR[BA] values.
4. Set the SDMR[CMD] bit.
5. For DDR, repeat from step 2 for the extended mode register.
6. Clear the SDCR[MODE_EN] bit.
That's pretty definite. And probably completely wrong. It is a "Really Big Clue" when the Example Code given in the SAME manual completely disobeys that:
18.8.12 Initialization Code
...
Write Extended Mode Register:
move.l #0x40010000, d0//Write LEMR to enable DLL
move.l d0, SDMR
Write Mode Register and Reset DLL:
move.l #0x048D0000, d0//Write LMR and reset DLL
move.l d0, SDMR
There's no "bit fiddling" in there at all. They're writing all the bits at once. Like you'd expect to with hardware. Like the Programmers know how the hardware works, but didn't tell the Documentation Writers.
So why is it (possibly) wrong? Most of the manual is a cut/paste/copy of a previous manual. Going back for years and through multiple products. So the above may have been correct for some hardware at some point in the past.
Archaeology of the different manuals can teach you a lot. If you search NXP's site for "Write the desired mode register value" you'll come up with a list of manuals, all saying to do the same thing. But in the same manuals, some of the SDMR registers are defined differently. Looking for the "evolutionary history":
- MCF5206E: DRAM only. No SDRAM. No SDMR Register
- MCF5235. No SDMR register, and you have to generate the required SDRAM control signals with some very strange methods.
- MCF5275: SDMR register, with CMD bit marked "R/W". Requires a "Dummy Read" to generate the SDRAM control signals.
- MCF5475, MCF5485: SDMR register, with CMD bit marked "R/W". Does not require the "Dummy Read". Not documented to "Auto Clear" the CMD bit.
- MCF5208, 5329, 5301x, 5373, 54455: SDMR register, with CMD bit marked "Write Only, returns 0 on read". Which is another way of saying the bit "Auto Clears".
- MPC5200: SDMR-equivalent register, but the entire register is write-only.
The design has evolved from "generate the signals yourself" to the more convenient "SDMR" register. The MCF5275 one has you set up this register, and then perform a separate cycle to force the hardware to do the work. Subsequent ones had setting the "CMD" bit perform the entire operation. I suspect the MCF5275 register was completely read-write (as writing to it didn't start any actions). When this changed, writing to the SDMR register starts a state machine running to perform the memory cycle, and then automatically clears the "CMD" bit. It may be that the MCF5475 and MCF5485 ones actually had a "write only" CMD bit, but the manual wasn't updated to say this until the manuals for the subsequent chips. The MPC5200 design is interesting. There's really no need to read this register back, so you can't.
The "Load Mode/Extended Mode Register Command" instructions haven't changed since the MCF5275 one's was changed to remove the "Dummy Write", so that might be a "missed edit".
Tom