0

This is the pinout I have for the flash memory W25Q128FV which I'm trying to interact with

enter image description here enter image description here

I'm trying to control it with a raspberry pi 3 B+.

Here's how I wired everything:

CS - GND
D0 - SPIMISO
WP - GND
GND - GND
VCC - 3.3v
HOLD - 3.3v
CLK - SPISCLK
DI - SPIMOSI

CS is in GND because datasheet says that in LOW, we can write/read from the chip, but I think this is wrong. I need to connect this to some raspberry pi pin that maybe is controlled by wiring pi.

I also enabled spi on raspberry and I'm using the library wiringPi with channel 0.

I'm writing like this (Rust code linked against -lwiringPi):

pub fn read_status_register_3(&self) -> [u8;2]{
    let mut slice :[u8;2] = [0;2];
    let mut data: [::std::os::raw::c_char; 2] = [0;2];
    data[0] = 0x11;
    let mut _r: i32 = 0;
    _r = unsafe{wiringPiSPIDataRW (self.spi_channel,data.as_mut_ptr(), data.len() as i32)};
    slice.clone_from_slice(&data);
    slice
}

but I get data to be all 0. I suspect something is wrong but I don't know if it's on the chip, on the wiring or on the software. This is a brand new chip by the way.

datasheet link: http://www.xmcwh.com/Uploads/2020-09-03/5f50d26953af2.pdf

Here's my Rust code with everything ready to test and dockerized, just ./run.sh, compile the Wiringpi/wiringpi with ./build and cargo run in w25qxx_spi: https://github.com/lucaszanella/w25qxx_spi/blob/b652db39d83521d7f018bd254c1b3dca03549f00/w25qxx_spi/src/w25q.rs

2
  • You're probably aware that wiringPi has been deprecated. It still works - at least I still use it occasionally, but if you've not used it much, you should be aaware that is uses a unique numbering scheme for GPIO pins. You can print those from wiringPi, or use this tool, and hover over the pin to see the "tool tip".
    – Seamus
    Mar 20 at 6:35
  • I suggest you get it working using a more supported environment such as C or Python. When that is working port the code to Rust.
    – joan
    Mar 20 at 8:43
1

Found the problem. Have to connecto CS to SPICS0 which is a pin on the rpi

1
  • 1
    Congratulations! Please "accept" your answer as the correct one when you are able. his will prevent the question from becoming a zombie :)
    – Seamus
    Mar 21 at 5:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.