The fact you need resistors between the pic32 and sdram data bus might indicate there is a bug in the driver
- you have left the portE direction OUT (even for a moment, ie few ns) while you read data from the sdram. Therefore, ie. in our sramc driver, we set always portE direction IN after any operation to be safe. Try to set portE to input (mind the pic32 errata - see our sramc driver) ALWAYS as default (even it would cost you more instructions).
ERRATA: I had similar symptoms with my sdramc driver last Xmas during development, but then I found out the setting the PORT direction to the INPUT does not work as expected
. This errata needs to be handled in this way (rd_sramc.c, l.39):
* Switch data bus to input.
static inline void data_switch_input ()
LAT_CLR(SW_DATA_PORT) = 0xff << SW_DATA_PIN; // !!! PIC32 errata
TRIS_SET(SW_DATA_PORT) = 0xff << SW_DATA_PIN;
asm volatile ("nop");
You have to CLR portE -set all bits LOW (via LATE), then set TRISE to input, do a NOP to be safe, and then you will get the portE set to INPUT. Doing single TRISE is not enough!
Latest Errata, item 26:
26. Module: PORTSBTW - using the resistors on the bus (ie between CPU and other circuitry) became famous in early 80ties in ZXSpectrum (ZX81?) as Clive used that as "full automatic passive bidirectional data bus driver" - at that time 470ohm resistors were used (CPUdata-470ohm-RAM-ULA). So whatever you did on the bus (ULA-RAM against CPU) you never got a "hard" bus collision. The bus collisions (outputs fired against outputs) were converted simply to heat
"When an I/O pin is set to output a logic high signal,
and is then changed to an input using the TRISx
registers, the I/O pin should immediately tri-state
and let the pin float. Instead, the pin will continue
to partially drive a logic high signal out for a period
The pin should be driven low, prior to being tristated,
if it is desirable for the pin to tri-state quickly."
PS: in order to support the retro-style idea you may use the resistors on the data bus (as well on CLK, WE). Use a 0612 smd dip pack. I would go with 220-270ohm for data bus (2x4res pack) and 33-68ohm for the control signals (1xpack). The driver shall be checked for the errata/bug stuff as well !
It shall work w/o the data bus resistors of course (plz make a test then w/o bus resistors), adding them increases the stability/reliability even more..In each case do use 4x 2k7 pullups (also a pack) on UDQM, LDQM, CS, WE, plz.Colour layout c2012 Pito. All rights reserved. United Colours of RetroBSD.