Content originally posted in LPCWare by wheels on Fri Feb 12 14:30:46 MST 2016
I'd question whether your initialization is correct. I'm not that familiar with SDRAM yet, but to me the problem looks as though the value you're writing may be persisting on the data bus through capacitance, and your single loop code allows the data to be read back before it decays away.
Try using the single loop, but putting a significant delay between the write and the read. If you get the same failure, then you aren't writing to SDRAM successfully.
Another test would be to use a single loop, but write two locations with different values each iteration, then read them back in order.
It may be worth doing a search on "memory test algorithm" or "RAM test" to be aware of some of the tricky bits involved in testing memory.