Hello
Got an atmega hooked up to an external 2kB SRAM via parallell lines where data and address lines are multiplexed (shared with an ADC, and OLED display). However I'm having some issues with data inconsistency from the SRAM. The micro is running at 4.9152Mhz.
I moved the heap to the external sram with the linker options; (address decoder enables SRAM from 0x1800 to 0x1FFF)
-Wl,--defsym=__heap_start=0x801800,--defsym=__heap_end=0x801fff -Wl,--relax
I tried running a sram-test program checking if any writing faults occures and then reading faults. This test completes without any errors at power up. However if I do a reset failures occures. If I power cycles again, no failures occures. This repeats.
I'm using the SRAM for a oled-display buffer. Space allocated with calloc;
uint8_t *oled_buffer;
oled_buffer = calloc(OLED_WIDTH * OLED_HEIGTH/8, sizeof(uint8_t));
External SRAM is initated with:
void SRAM_init() {
// External memory
MCUCR |= (1 << SRE); // External memory enable
SFIOR |= (1 << XMM2); // Masking PC7-PC4 for JTAG interface
}
And as before with the sram-test, the OLED renders perfectly after a power cycle, but after a reset artifacts appear on the display, aswell as missing pixels etc. Artifacts happens during regular re-rendering aswell, only the very first drawing after a power cycle is perfect.
Does anyone have any suggestions? Is this noise issues or possible chip issues (chips arent new)?
Is it necessary to have a LP-filter on the ALE-line as well as pull down resistor?
Address latch:
http://www.ti.com/lit/ds/sdas048d/sdas048d.pdfSram:
https://ntnu.blackboard.com/bbcswebdav/pid-442669-dt-content-rid-17211924_1/courses/194_TTK4155_1_2018_H_1/SRAM%20CY7C185.pdfAtmega 162:
https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2513-8-bit-AVR-Microntroller-ATmega162_Datasheet.pdf