The code seems to be correct, but the application does not work.

Ensure that the hardware is set up correctly (for example, using chip selects). Some memory expansions require a special access mode (for example, only word accesses). If memory is accessible only in a certain way, use inline assembly or use the volatile keyword.