Reading Serial Flash Manufacture/Device ID via SPI.transfer

hello please help me. i want to read chingis Pm25LD010 Manufacture/Device ID via SPI.transfer
datasheet
i saw post
http://forum.arduino.cc/index.php?topic=263839.0
and write code

#include <SPI.h>

#define SERIAL_BAUD 9600
#define MEMORY 4 // Chip select pin

void setup()
{
  Serial.begin(SERIAL_BAUD);
  Serial.print("Start...");

  SPI.begin();
 
   
  SPI.setBitOrder(MSBFIRST);

}

void loop()
{
SPI.transfer(0x9F);
 
byte response1 = SPI.transfer(0x00);
byte response2 = SPI.transfer( 0x00);
  Serial.print("Response: ");
  Serial.println(response1);
  Serial.println(response2);
  delay(1000);
}

but it not work for my chip :frowning:

Hello and welcome,

Have a look at this library: GitHub - LowPowerLab/SPIFlash: Arduino library for read/write access to SPI flash memory chips

Edit: I was probably wrong about the JedecID

nobotro:
but it not work for my chip :frowning:

What did it print?

Try:

  Serial.println((int) response1, HEX);
  Serial.println((int) response2, HEX);

thanks for answers

guix:
Hello and welcome,

Have a look at this library: GitHub - LowPowerLab/SPIFlash: Arduino library for read/write access to SPI flash memory chips

The JedecID of your chip should be 0x2110 (or maybe 0x1021), as seen in the table on page 11 in the datasheet.

i tried this library and use example code ,it write "Sta" in serial and nothing heppend ofter

answer

Start...Response: 0
0
Response: 0
0
Response: 0
0
Response: 0
0
Response: 0
0
Response: 0
0
Response: 255
255
Response: 255
255
Response: 255
255
Response: 255
255
Response: 255
255
Response: 255
255
Response: 255
255
Response: 255
255
Response: 0
0

i have connectdd pins lke this ,in arduino uno


is it correct? i see pin connection in that tuturial http://www.arduino.cc/en/Tutorial/SPIEEPROM

Please post your wiring. Maybe a photo?

unfortunately i havenot any hight or normal quaility camera,to take picture.

since ceate topic i have seen many tuturials

http://www.instructables.com/id/How-to-Design-with-Discrete-SPI-Flash-Memory/?ALLSTEPS
http://www.sodnpoo.com/posts.xml/arduino_mx25l_4mb_flash.xml

and no result.still 255 or 0
do #hold pin be connected in 3.5 v?

Do you have access to a pencil, some paper, and a scanner? A lot of multi-function printers these days also scan. Or how about a Paint program where you can draw your schematic?

You can download free schematic software for Windows from http://www.expresspcb.com/

here is.
insted of attiny i have chingis pm25ld010

If you are powering it from 3.3V you may need a level-changer on the MISO/MOSI/SCK lines.

can i use +5v instead of 3.3V for my chip and do i still need level-changer if i use +5V ?

The datasheet quotes Vcc as being from 2.3 to 3.6V.

The absolute maximum rating for Vcc is 6V. Possibly running it at 5V would be OK, however it exceeds the quoted input voltage range.

If you supply 5V to it, you won't need the level converter (I don't think). However you would be operating outside recommended voltages if you do, so don't complain to me if it doesn't work. The level converter would be the safer option.

thanks for answers.i change wiring like that

and it sometimes gives me correct respons.
for example in 2000 sketch ciyle it gives me correct answer in 2 time and incorrect in 1998 time.
ciyle count is changing sometimes it is 10 or 1500 or 15434 ... etc insted of 2000

Try slowing SPI down. After:

  SPI.begin();

Add:

  SPI.setClockDivider (SPI_CLOCK_DIV64);

on 64 no result but i set smallest value SPI.setClockDivider (SPI_CLOCK_DIV2); and in 10 cycle average 4 or 5 response is correct,can i set clockdivider less when 2?

my setup:

void setup(void) {
  SPI.begin(); 
  SPI.setClockDivider (SPI_CLOCK_DIV2);
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  
  Serial.begin(9600);
  Serial.println("");
  Serial.println("Ready"); 
}

No you cannot. And a smaller divider means faster SPI. If it is failing, I would be doing slower rather than faster.