LowPowerLab Forum

Hardware support => General topics => Topic started by: gurari on July 10, 2015, 03:32:17 PM

Title: SPI FLASH question
Post by: gurari on July 10, 2015, 03:32:17 PM
Hello,
I'm trying to install a SPI FLASH chip on my DIY Moteinos. At home I have some ATMEL AT25F512B SSH chips which I hope I can use. I've soldered one but when I listen to serial when node is programmed with the wireless programming example sketch I'm reading: Start node...SPI Flash Init FAIL!
In the sketch I'm using SPIFlash flash(FLASH_SS, 0x1F44); but still FAIL, so I'm wondering if the chips are not wrong?
Title: Re: SPI FLASH question
Post by: Felix on July 10, 2015, 04:48:47 PM
2 things:
- Check the datasheet commands to match the ones in the library.
- make sure the signature JEDEC bytes are correct, also from datasheet
Title: Re: SPI FLASH question
Post by: gurari on July 11, 2015, 01:04:26 AM
Quote from: Felix on July 10, 2015, 04:48:47 PM
2 things:
- Check the datasheet commands to match the ones in the library.
- make sure the signature JEDEC bytes are correct, also from datasheet

I've checked the commands in datasheet and in the library - they are the same, so I'm expecting that the problem should be somewhere else.

When I read more carefully I found that the signature JEDEC bytes for ATmel chips should be 0x1F65 but I'm still getting FAIL message trying to init the FLASH. I'm seeing that there is Device ID (part 2) in the datasheets - did I have to insert it somewhere?
Title: Re: SPI FLASH question
Post by: TomWS on July 11, 2015, 07:21:35 AM
Quote from: gurari on July 11, 2015, 01:04:26 AM
Quote from: Felix on July 10, 2015, 04:48:47 PM
2 things:
- Check the datasheet commands to match the ones in the library.
- make sure the signature JEDEC bytes are correct, also from datasheet

I've checked the commands in datasheet and in the library - they are the same, so I'm expecting that the problem should be somewhere else.

When I read more carefully I found that the signature JEDEC bytes for ATmel chips should be 0x1F65 but I'm still getting FAIL message trying to init the FLASH. I'm seeing that there is Device ID (part 2) in the datasheets - did I have to insert it somewhere?
Some Flash chips have 3 byte 'JEDEC' IDs.  The SPIFlash library only looks at the first two, which may, in fact, simply be two Manufacturer ID bytes.  The library uses Command 9F (Read JEDECID) to read the device.  If you still get an error from flash.initialize(), try this:


  if (!flash.initialize())
  {
      word my_flash_id = flash.readDeviceId();
      Serial.print("Flash Initialize failed! Here is the ID of my flash:");
      Serial.println(my_flash_id,HEX);
      ...
   }


Tom
Title: Re: SPI FLASH question
Post by: dale.s on July 12, 2015, 01:53:32 PM
The device ID isnt accually needed if its the only thing on the pin.  I had problems with a flash chip that would just not respond, untill i left out the id.

Just try
SPIFlash flash(FLASH_SS);
Title: Re: SPI FLASH question
Post by: gurari on July 12, 2015, 03:44:53 PM
Thank you all for the ideas you gave me!
I've decided to test another FLASH chip on another Moteino and it started working when 1F65 code was entered (like should be according to datasheet). I'll try to resolder the first flash chip to see where is the problem.
Title: Re: SPI FLASH question
Post by: TomWS on July 13, 2015, 06:36:54 AM
Quote from: dale.s on July 12, 2015, 01:53:32 PM
The device ID isnt accually needed if its the only thing on the pin.  I had problems with a flash chip that would just not respond, untill i left out the id.

Just try
SPIFlash flash(FLASH_SS);
I hadn't noticed this behavior in the code.  Good suggestion!

Tom