I am using the S12XE and LY62W102516 1024K X 16 BIT LOW POWER CMOS SRAM.
When I write to the external SRAM and then read back the data, I do not get correct values.
Example of write and read.
24 24 24 24 24 24 24 24 24 24 // Write
00 20 24 24 24 24 24 24 24 24 // Read
This is the related code.
#define WRITE_BYTE_B(a,d) *((unsigned char *far)(a+0x200000UL))=d
#define READ_BYTE_B(a) *((unsigned char *far)(a+0x200000UL))
uint8_t readStr[16];
for(addr = 0; addr < 10; addr++) {
WRITE_BYTE_B(addr,0x24); // write RAM address
}
for(addr = 0; addr < 10; addr++) {
readStr[addr] = READ_BYTE_B(addr); // read RAM address
}
Ray.
Hi Ray,
Unfortunately I am not sure what could be reason for that behavior.
Problem could be in connection of address bits or some timing issue.
Please look at attached draft of document with external bus examples.
In case of MEBI module at S12XE, the data bus is always 16 bit. Please check how you connected A0 pin in SRAM memory.
Example code use MRAM with 35ns read and write cycle. Your SRAM may have 55 or 70ns read/write cycle. In that case some wait states may be necessary for fastest MCU bus clock (50MHz). See chapter 5.4.4 Stretched External Bus Accesses in RM for more details. You may also try temporarily decrease bus clock for testing whether it could be the root cause.
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------