[Solved] Unable to read SPI EEPROM using Arduino - Page 1
Forum section: electronics / general

author: destevez
author_rank: Newbie
timestamp: August 22, 2016, 03:32:08 pm
content: I'm trying to read the EEPROM in a RS92-SGP radiosonde (seehttps://brmlab.cz/project/weathersonde/start). For the purposes of this post, the only important thing is that this device uses a custom CPU and it holds the code and settings in a M95256-W EEPROM that is hooked to the CPU via SPI. The SPI bus and EEPROM run at 2.85V.It should be possible to read and write the EEPROM of this thing by connecting an external microcontroller to the SPI bus and holding the reset line of the custom CPU to ground (to prevent it from trying to talk to the EEPROM). For instance, there is this Arduino code:https://brmlab.cz/project/weathersonde/eeprom_mgmtI'm using an Arduino nano to try to read the EEPROM, but I'm unable to do so: the output of the EEPROM stays high-impedance all the time. The Arduino runs at 5V, but it shouldn't damage anything even if I connect it directly to the SPI bus, as I'm doing. I've also tried to use different voltage translation schemes, without any luck.What puzzles me is that the CPU can talk to the EEPROM fine, and if I capture the SPI bus with a scope I see that the CPU is essentially doing the same as my Arduino, except for the voltage levels, the bus speed and the fact that the Arduino holds MOSI high when the bus is idle but the CPU holds it low (this shouldn't matter at all). I've also reviewed the whole datasheet of the EEPROM, but I don't see where the problem is.This is what the Arduino does:https://postimg.org/image/wuajixbpn/This is what the custom CPU does:https://postimg.org/image/bl2yetf91/I'm probably doing something terribly stupid and simple, but I can't figure out what.

author: tatus1969
author_rank: Super Contributor
timestamp: August 22, 2016, 04:07:06 pm
content: it is not possible from your pictures, but most probably you are not using the correct SPI mode (CPOL, CPHA). Maybe you can post a zoom of a few clocks, starting with /CS going low.To check if you have voltage translation problems (don't use the 5V arduino's outputs to drive that 2.85 referenced inputs, you may put the EEPROM into latchup or even destroy it), you can try with slower clock rates and to add pullups to the EEPROM's supply. Then use the arduino to drive LOW only for /CS and MOSI, use high-z or GPIO input mode to generate high levels (by the pullups).

author: destevez
author_rank: Newbie
timestamp: August 22, 2016, 04:44:47 pm
content: Yes. The SPI mode is the correct one.It turned to be some weird voltage translation stuff. When the onboard CPU is in reset, the SCK and MOSI lines are held low (0V) by a relatively low impedance (about 250R, but the I-V curve is nonlinear), and the CS is held high (2.85V) by low impedance (about 300R, I-V curve non-linear). The MISO line is truly floating or connected to very high impedance.I've used 100R series resistors on the SCK and MOSI lines. This gives me around 3V on the EEPROM pins when the Arduino is driving this lines high to 5V. When the Arduino drives this lines low to 0V, I get 0V on the other side as well.The CS is more problematic, because a low enough series resistor to make the Arduino drive it low effectively will make the voltage too high when the Arduino drives it to 5V. Therefore, I've connected this line to the collector of an NPN transistor. The emitter is grounded and the base is conected through 1k to the CS pin of the Arduino. I drive the CS pin on the Arduino in an inverted fashion. Thus, the NPN transistor pulls the EEPROM CS to ground when CS is active and the rest of the time the EEPROM CS is pulled high by the onboard CPU.With this setup I'm starting to get data out of the EEPROM.

author: tatus1969
author_rank: Super Contributor
timestamp: August 22, 2016, 07:38:03 pm
content: great

author: thieringpeti
author_rank: Contributor
timestamp: January 01, 2019, 01:18:01 pm
content: Now RS92 is discontinued. Get some RS41's and rock with the STM32F100 MCU, the uBlox GPS and a Si4032 radio :-)Open source software is available on GitHub!https://github.com/df8oe/RS41HUP