W25M512JV interfacing with atmega32

Go To Last Post
30 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to interface W25M512JV (16 PIN Package)with ATMEGA 32 (operating at 3.3V,8Mhz, compiler winavr, software based SPI). This is my code.

 

I want to write data on 200 location of rom. and reading same location and coping data on variable "rom_data".But I always get high on  MISO of rom. (Reset pin is connected with VCC and I using PIN 8 FOR MISO, PIN 15 FOR MOSI, PIN 16 FOR CLK).  

 

unsigned char rom_data;

int main(void)

{

 

unsigned char spi_counter=0XAA;

unsigned char rom_address=200;

 

while(1)

{

       ms(250);
       FlashWriteData(rom_address,&spi_counter,1);                           //for writing data on 200 location
       ms(250);
       FlashReadData(rom_address,&rom_data,1);                              //For reading data 

}

 

// Function for writing data on flash

//Input address, data, no of byte to write

 

void FlashWriteData (unsigned long address, unsigned char const *data,int size)

 {

  unsigned char command[4];

 

  unsigned char data_var;

  data_var=*data;

 

  WriteEnable();   us(550);       //Send command to disable write protection send command 0X06

  WriteUnprotect();   us(550);  //Global block unclock --0X98 command 

 

 

  /*  This section writes data.  The first character is the write command */

 

     CS_L;

     us(550);

 

  command[0] = 0x02;                                                      //write command 

  command[1] = (unsigned char)(address >> 16);

  command[2] = (unsigned char)(address >>  8);

  command[3] = (unsigned char)(address >>  0);

 

     soft_spi_data_write(command,4);                                 //send write command 

     soft_spi_data_write(&data_var,1);                                 //read data form rom

 

     us(550);

     CS_H;

 

    while(FlashReadStatus() == 0x03);                              //this ensure read operation are completed

 

    us(200);

    WriteProtect();                                                            //after writing data set lock flag  

}

 

//Function for read data form memory

//Input- address, size(not used yet), unsigned char pointer for returning data.

 

 unsigned char FlashReadData (unsigned long address, unsigned char *data,unsigned long size)

 {

  unsigned char command[4];

  CS_L;

  us(550);

   /*Initialize peripheral for SPI */

   /*This section reads back data.  The first character is the read command */

 

      command[0] = 0x03;                                                  //send read command 

    command[1] = (unsigned char)(address >> 16);

    command[2] = (unsigned char)(address >>  8);

    command[3] = (unsigned char)(address >>  0);

 

   soft_spi_data_write(command,4);                                   //send read command  

 

   us(100);

   *data=soft_spi_data_read();

   us(550);

 

   CS_H;

  return(0);

 }

 

 

 

 

void WriteUnprotect (void)

 {

   unsigned char command[2];

 

  /* send write enable command */

  //Erase_Flash_Chip();

 

   GlobalBlockProtectionUnlock();

 

   ms(10);

 

   CS_L;

   ms(5);

 

    command[0] = 0x01;

    command[1] = 0x00;

 

   soft_spi_data_write(command,2);

   ms(5);

   CS_H;

 }

 

 void WriteEnable (void)

 {

  /* send write enable command */

  unsigned char command = 0x06;

 

    CS_L;

    us(500);

 

  //do{

 

     soft_spi_data_write(&command, 1);

 

  //loop++;

  //}while ((FlashReadStatus() & FLASH_WEL) != FLASH_WEL);

 

  us(500);

    CS_H;

 

 }

 

 

void GlobalBlockProtectionUnlock (void)

 {

  /* send gloal block unlock command */

   unsigned char command = 0x98;

 

   /* Initialize peripheral for SPI */

    CS_L;

 

    us(500);

    soft_spi_data_write(&command,1);

 

    us(500);

    CS_H;

 

    return;

 }

 

 

 

 

/*write data in 00 mode*/

 

void soft_spi_data_write(unsigned char *data,int no){

   unsigned char i, maskdata = 0X80;  

   int loop;

 

  for(loop=0;loop<no;loop++){

 

  for(i= 0;i<8;i++)

  {

 

  if(*(data+loop) & maskdata){

    d_out_h;

  }

 

 else{

 d_out_l;

 }

 

 maskdata >>= 1;

 

    clk_h; 

    ms(1)

    clk_l; 

    ms(1);

  }

  }

  d_out_l;

  return;

}

 

/*read data in 00 mode*/

unsigned char soft_spi_data_read(void)

 {

  unsigned char i=0;

  _Bool pin;

 

  data_sp=0;

 

   while(i<8)

   {

      d_out_h;

 

  clk_h;

  ms(1);

 

  clk_l;

  ms(1);

 

     pin=read_spi;

 

  if(pin==true)

      {

      data_ty=0X01;

      }

  else

  {

     data_ty=0X00;

  }

  data_sp=data_sp<<1;

  data_sp|=data_ty;

  i++;

   }

 

  return(data_sp);

}

Last Edited: Thu. Jun 21, 2018 - 03:53 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For an example of using spi dataflash, look at the code for the AVR Butterfly here:  https://www.microchip.com/Develo...

Down load the application code and look at the dataflash.c/h files.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Silly question but if it is a mega32 that has a real hardware SPI peripheral then why are you implementing:

void soft_spi_data_write(unsigned char *data,int no){
    unsigned char i, maskdata = 0X80;  //0x80;
    int loop;
    
    for(loop=0;loop<no;loop++){
        for(i= 0;i<8;i++)
        {
            if(*(data+loop) & maskdata){
                d_out_h;
            }
            else{
                d_out_l;
            }
            maskdata >>= 1;
    
            clk_h;
            ms(1)
            clk_l;
            ms(1);
        }
    }
    d_out_l;
}

Surely you just enable the SPCR with SPEN/MSTR and then later write to SPDR when you have a byte to send - it does all the data and clock signal generation for you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

samic45mit1 wrote:

...This is my code.

 

 

Something has gone wrong with your post. Your code seems to have been copied OK but none of your comments have made it.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian, there is a comment there:

unsigned char i, maskdata = 0X80;  //0x80;

 

David (aka frog_jr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for replay,

 

But for testing purpose I use software SPI. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

samic45mit1 wrote:

Thanks for replay,

 

But for testing purpose I use software SPI. 

please explain the reason why........

 

you have a hardware peripheral that solves all potential timing issues and makes life a lot simpler as you only need to write a couple of registers, but yet you want to make your own version.

I suggest you start with using the SPI peripheral and when that works, just change the code to use these lines for your self developed software SPI. In that case you at least know that your hardware is wired correctly and that everything should work, thus you then only have to get your software SPI working.

 

Also the code you have should for sure give compile errors as I spotted at least a ' ;' missing on one line.

 

Another note is that in the future you better put comments in your code. That for a start will help you when you are trouble shooting. While reading the comments you might all of the sudden see things that are right in the comments but are wrong in your code. Plus that when you have to hand over the code to other (for use or in this case for debugging) they will understand what you want to do or have done and as such can use or update the code to what it is supposed to do.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

samic45mit1 wrote:
Thanks for replay

You mean, "reply" ?

 

  • "replay" is to play something again;
  • "reply" is a response to a question.

 

#ReplayReply

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK form next time I take care about comments.

 

When I try to read register of rom. I find SOFT SPI read/write function working properly(crossed check with a DSO). I think problem  is in "FlashWriteData" function. There are some write protection command in data sheet,I use 0x06 to disable write protection and 0X98 Global block unclock but still I am not able to write. So, there is some fix initialization procedure?(like in spi based graphical lcd) for this type of memory  

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

The first job is to write a function to read the Flash ID. If you can do that successfully, all other read/write operations should work too.
.
It is worth spending time to write neatly formatted code with sensible amount of comments. This is for YOUR benefit !!
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

there is no lock pin on the chip you are using?

most lock commands are there to lock sectors of the chip, but it might be that there is a 'lock' pin too and that then locks the entire chip for writing as long as it is set to specific level.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Comments are not something to be bolted-on as an afterthought - they should be an integral part of creating the code.

 

In fact, it can be useful to write the comments before you fill-in the code;  this helps you to think about what your code needs to do - before getting into the detail of how to do it.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are both hardware and software "locks". All 25xxxxx chips work in a similar way. Bigger Flash chips have some extra commands and features.
All very straightforward once you use a single SPI function.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I read the devise ID by sending command 0XAB followed by three dummy byte (page no 24 of datasheet,8.1.2 Instruction Set Table). And response is 0X30 (in variable i1). This is the function I use.

Please see the attachment for datasheet.

 

 

/*********************************************************************************************************************************/

 

unsigned char i1;                                               //Globel variable

 

/*Function for read devise ID*/

 

void read_devise_id(void)
 {
   unsigned char command=0XAB;                     //Command for reading devise ID 
   

   CS_L;                                                          //Chip select low

   us(80);                                                        //80 micro second delay
   

   soft_spi_data_write(&command,1);               //Send command 0XAB 
   soft_spi_data_write(&command,1);               //Dummy write
   soft_spi_data_write(&command,1);               //Dummy write
   soft_spi_data_write(&command,1);               //Dummy write

   

    i1=soft_spi_data_read();                              //read the devise ID  
   

   us(80);                                                        //80 micro second delay

   CS_H;                                                         //Chip select high

   return;
 }

 /***********************************************************************************************************************************************/ 

Attachment(s): 

Last Edited: Fri. Jun 22, 2018 - 07:22 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is the function I am using to write data on memory. And I use Write enable (0X02) and global block unlock (0X98). But when I read data response is always same (0XFF). 

 

void FlashWriteData (unsigned long address, unsigned char const *data,int size)

 {

  unsigned char command[6];

  unsigned char data_var;

  data_var=*data;

 

  address=100;                                                                            //For testing I use fix address 100. 

 

  WriteEnable();   us(550);                                                           //Write enable function send command 0X06 (8.1.2 Instruction Set Table PAGE 24), The CS_L,CS_H is given inside this function so not                                                                                                      // used here
                          

  WriteUnprotect();   us(550);                                                      // Send command 0X98 for global block unlock, The CS_L,CS_H is given inside this function so not used here

 

  /*  This section writes data.  The first character is the write command */

 

   CS_L;

   us(550);

 

  command[0] = 0x02;                                                                 //Page program command follow by three byte address                                                            

  command[1] = (unsigned char)(address >> 16);

  command[2] = (unsigned char)(address >>  8);

  command[3] = (unsigned char)(address >>  0);

  command[4] =0XAA;                                                                  //Data , This is I try to write on location 100   

 

     soft_spi_data_write(command,1);                                           //Send 0X02 command 

     soft_spi_data_write(command+1,1);                                       //Address

     soft_spi_data_write(command+2,1);                                       //Address

     soft_spi_data_write(command+3,1);                                       //Address 

     soft_spi_data_write(command+4,1);                                       //data to write in 100 location

 

    

     us(550);

     CS_H;                                                                                   //CS high

 

    //while(FlashReadStatus() == 0x03);                                       

    //us(200);

    //WriteProtect();

}

Last Edited: Fri. Jun 22, 2018 - 07:45 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

just a couple of questions on the HW side......

 

- miso (chip DO) and Mosi (chip di) and clk lines are connected correctly?

- reset is toggled as per datasheet?

- You have double checked that the way you address the chip and connected all the not used IO lines is as per the datasheet to have it run in the 4 wire SPI mode (DI, Do, SCK, CE) and not the quad SPI mode.

 

- have you checked with a scope or logic analyzer that what is send to the chip is what you expect it to be?

- Is the SPI set up correctly with regards to clock polarity and data read polarity?

 

The chip does not have a hardware lock pin, so that is one question solved ;)

 

- Are you able to read the status register (3 bytes) ?

from what I have read and know from other chips that should always be readable, so unless you can read that back successfully do not bother in trying to do anything else as this should ba always readbale to have knowledge on the set security level of the chip.

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

meslomp wrote:
- miso (chip DO) and Mosi (chip di) and clk lines are connected correctly?

- You have ... connected all the not used IO lines is as per the datasheet

The best way to answer these questions is to post your schematic (aka "circuit diagram")

 

See Tip #1 for instructions - also how to properly post source code

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It looks as if you have written your functions quite neatly.    I am horrified by the use of void  but hey-ho,   if you can keep track of global variables ....

 

Looking at the PDF,   I can't see the correct return value for the 0xAB command.    It looks like 0x9F and not 0x30.

 

There are several other ID commands.    Do they return the correct values?

 

Seriously,   your approach is fairly long-winded.    It makes it harder to follow.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

david.prentice wrote:
All very straightforward once you use a single SPI function.

in other words, don't keep manually re-typing the same sequence:

 CS_L;

 us(550);

 soft_spi_data_write(command,1);                                         //Send 0X02 command 
 soft_spi_data_write(command+1,1);                                       //Address
 soft_spi_data_write(command+2,1);                                       //Address
 soft_spi_data_write(command+3,1);                                       //Address 
 soft_spi_data_write(command+4,1);                                       //data to write in 100 location

 us(550);

 CS_H;

The chances of making an error are too high and, once you fix a problem in one place, you have to remember to do the same in all the other places!

 

Write a function to do that!

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. miso (chip DO) and Mosi (chip di) and clk lines are connected correctly-YES

 

2. reset is toggled as per datasheet--Connected to VCC

 

3. You have double checked that the way you address the chip and connected all the not used IO lines is as per the datasheet to have it run in the 4 wire SPI mode (DI, Do, SCK, CE) and not the quad SPI mode-- Yes four wire SPI mode is used DO(IO1) with MISO, DI(IO0) with MOSI, CLK(PIN 16) with microcontroller pin, CS is also connected with microcontroller (Please note I use software based SPI)  and IO3,IO2 are not connected, reset is connected to VCC.

 

4. have you checked with a scope or logic analyzer that what is send to the chip is what you expect it to be-- The SPI mode is 0 so data is set on ricing edge and latch in falling edge. I also refer a application note form microchip and wave form  and clock polarity are correct (Please see the attachment). 

 

5.  Are you able to read the status register -yes status register one(read command 0X05) output=0X00, status register two(read command 0X35) output=0X34, status register three(read command 0X15) output=0XC0. I am not sure this is correct  value but I am getting same output (I try thee times).

 

 

Attachment(s): 

Last Edited: Fri. Jun 22, 2018 - 09:07 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
Write a function to do that!
Well for something like:

 soft_spi_data_write(command,1);                                         //Send 0X02 command 
 soft_spi_data_write(command+1,1);                                       //Address
 soft_spi_data_write(command+2,1);                                       //Address
 soft_spi_data_write(command+3,1);                                       //Address 
 soft_spi_data_write(command+4,1);                                       //data to write in 100 location

I would have thought a for() loop would suffice:

for (int i=0; i < 5; i++) {
    soft_spi_data_write(&command[i], 1);
}

Though I suppose you could have a generic:

void spi_send_bytes(char * addr, uint8_t len);
    for (int i=0; i < len; i++) {
        soft_spi_data_write(addr++, 1);
    }
}

then:

spi_send_bytes(command, 5);

I'm still a little perplexed as to why this is doing bit bang SPI on a micro that has a real SPI ?? Does the soft SPI do the write SPI mode - implementing CPOL and CPHA correctly for the target device?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So where is your schematic (aka "circuit diagram"), then?

 

frown

 

I am not sure this is correct  value but I am getting same output (I try thee times).

Then that is certainly something that you need to confirm before moving on!

 

If it's rubbish, it doesn't help that it's consistent rubbish ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How I can make sure this is correct value??. There is any way to find out?

 

And I am using a development board  so I need some time to make its schematic but For connection I sure they are correct and waveform are also appear on correct pin when I check them on DSO. 

 

But Pin connection with atmega32 are

 

1. PB5-W25M512JV PIN 15

2. PB6-W25M512JV PIN 8

3. PB7-W25M512JV PIN 164

4. PB4-W25M512JV PIN 7

 

5. W25M512JV-reset is connected with VCC

6. W25M512JV PIN 1--NC

7. W25M512JV PIN 2-VCC

8. W25M512JV PIN 4,5,6-NC

9. W25M512JV PIN 9-NC

10. W25M512JV PIN 10-GND

11. W25M512JV PIN 11,12,13,14-NC

 

 

 

Last Edited: Fri. Jun 22, 2018 - 09:44 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

samic45mit1 wrote:
How I can make sure this is correct value??. There is any way to find out?

That will be in the datasheet.

 

And I am using a development board  so I need some time to make its schematic

So why not just post a link to the development board??

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
That will be in the datasheet.

For example:

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

W25M512JV is not part of development board and register are 8 bit so they have some value. But as I told I check three times and even when I power off and then again power on supply and then read, register value are same.

 

 

Last Edited: Fri. Jun 22, 2018 - 09:53 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use the 0x9F command.

For an Amic A25L032 chip,  it returns 0x37, 0x30, 0x16

For your W25M512, it returns 0xEF, 0x71, 0x19 (I think)

 

I would not choose the 0xAB command.   First check the documented command.   Then see what 0xAB returns.

 

David.

 

Edit.   From Arduino SerialFlash library:

//			size	sector			busy	pgm/erase	chip
// Part			Mbyte	kbyte	ID bytes	cmd	suspend		erase
// ----			----	-----	--------	---	-------		-----
// Winbond W25Q64CV	8	64	EF 40 17
// Winbond W25Q128FV	16	64	EF 40 18	05	single		60 & C7
// Winbond W25Q256FV	32	64	EF 40 19	
// Spansion S25FL064A	8	?	01 02 16
// Spansion S25FL127S	16	64	01 20 18	05
// Spansion S25FL128P	16	64	01 20 18
// Spansion S25FL256S	32	64	01 02 19	05			60 & C7
// Spansion S25FL512S	64	256	01 02 20
// Macronix MX25L12805D 16	?	C2 20 18
// Macronix MX66L51235F	64		C2 20 1A
// Numonyx M25P128	16	?	20 20 18
// Micron M25P80	1	?	20 20 14
// Micron N25Q128A	16	64	20 BA 18
// Micron N25Q512A	64	?	20 BA 20	70	single		C4 x2
// Micron N25Q00AA	128	64	20 BA 21		single		C4 x4
// Micron MT25QL02GC	256	64	20 BA 22	70			C4 x2
// SST SST25WF010	1/8	?	BF 25 02
// SST SST25WF020	1/4	?	BF 25 03
// SST SST25WF040	1/2	?	BF 25 04
// SST SST25VF016B	1	?	BF 25 41
// SST26VF016			?	BF 26 01
// SST26VF032			?	BF 26 02
// SST25VF032		4	64	BF 25 4A
// SST26VF064		8	?	BF 26 43
// LE25U40CMC		1/2	64	62 06 13

So the middle ID byte might be 0x40 and not 0x71

Last Edited: Fri. Jun 22, 2018 - 10:18 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, I think this is the problem, status register 2 having value of 0x34 and as per datasheet it is Security Register Lock Bits so that why I am not able to write anything. I change the IC and test it again.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The W25Mxxx series is different to the more common W25Qxxx series.   But they still have similar commands and features.

 

When you get the expected return values from the different ID commands,   you know that your code is correct.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Just to show how straightforward a function can be:

void Get_Identification(byte data[3])
{
    SLAVESELECT;
    SPI_Transfer(RDID);
    data[0] = SPI_Transfer(0xFF);
    data[1] = SPI_Transfer(0xFF);
    data[2] = SPI_Transfer(0xFF);
    SLAVEDESELECT;
}

Not my code.   RDID is 0x9F.    Life is so much simpler with a single SPI function.

 

David.