This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM: 16-bit RAM non-byte addressable

I have a 16-bit wide RAM that doesn't have the ability to be byte addressed. However, the compiler is compiling the code with instructions that write single bytes. This is resulting in data overriding other data. Is there a way to tell the compiler that the memory can only be accessed using 16-bit data so that my RAM doesn't get corrupt?

  • Is there a way to tell the compiler that the memory can only be accessed using 16-bit data so that my RAM doesn't get corrupt?

    No, there is not.
    You can try some workarounds, though. For example,
    1) Perform all accesses to the 16-bit RAM through dedicated functions. The functions will do the necessary magic.
    2) If possible, use a portion of address space accesses to which cause exceptions. Perhaps, you can intercept those exceptions and use them to access your RAM instead.

  • However, the compiler is compiling the code with instructions that write single bytes

    Hmm. Can you post your code here, or at least to give us a taste of it?
    As mike mentioned, you can write your own functions to do it - but then again you'd need the compiler yet again...Or try assembly instead.

  • I guess I should clarify that statement. What I mean, is that there is some code that uses the char data structure, which is 8-bits. So, the compiler spits out a bunch of STRB instructions, which are 8-bit stores. So, if I wanted to write the value of 0x04 to address 0x0 and then 0x28 at address 0x1. The compiler does a STRB 0x04 to location 0x0. My SDRAM gets the value 0x0404 on its data pins and locations 0x0 and 0x1 get the data 0x0404. Then it does a STRB 0x28 at location 0x1. This repeats overriding the original data at location 0x0. In the end I get 0x28 at addresses 0x0 and 0x1.

  • Would it be possible to fix this by just converting all the data that use the 8-bit data structures to 16-bit? For the most part the SDRAM is used in conjunction with a 320 x 480 TFT LCD screen, which is connected for 16-bit RGB mode. Therefore, the majority of the data is 16-bit.

  • Would it be possible to fix this by just converting all the data that use the 8-bit data structures to 16-bit?

    It probably would. But the compiler is still allowed to use byte-wise accesses. To be absolutely sure, you'll have to inspect all code emitted by the compiler. If functional tests can do it, it would probably be easier to do.

  • Ok, sounds like it might be worth looking into, although, I'll probably just hook up the DQM lines in the future. But for now, that should suffice.