Teensy 3.2 / SPI Flash Memory Erase Issue

Status
Not open for further replies.

TyN101

New member
Hello all,

I've been working with a Teensy 3.2 and the 1Gbit version of the SPI flash memory add-on purchased here for some time now. Up until now, I have been using the supplied source code without issue. This source code can be found here. To be clear, the flash_read_status, flash_page_program, flash_read_pages, and flash_chip_erase functions have been tested and work without issue. However, my usage needs have changed, and I now need to use the flash_erase_pages_sector function. This is where my problem arises. The function does not seem to work. The program hangs when the function is called, and the amount of time the program hangs is proportional to the number of times the function is called, leading me to believe that the chip is in fact doing something. However, when I read the pages I attempted to erase with the function, they remain unchanged following the call.

My source code is lengthy and complex, but nonetheless it is attached (View attachment SPI_FlashFileSystemBaseSketch.ino). However, within my code the function is used in the simplest sense. When I want to erase a sector containing a page, the function is called with that page as the parameter. All of my code is done in the Arduino IDE, on a Windows 10 computer.

Here is the function in the supplied source code file for the memory board:
Code:
//=====================================
// Tse Typ=0.6sec Max=3sec
// measured 549.024ms
// Erase the sector which contains the specified
// page number.
// The smallest unit of memory which can be erased
// is the 4kB sector (which is 16 pages)
void flash_erase_pages_sector(int pn)
{
  int address;

  write_pause(); 
  // Send Write Enable command
  digitalWrite(f_cs, LOW);
  SPI.transfer(CMD_WRITE_ENABLE);
  digitalWrite(f_cs, HIGH);
  
  digitalWrite(f_cs, LOW);
  SPI.transfer(CMD_SECTOR_ERASE);
  // Send the 3 byte address
  address = page_to_address(pn);
  SPI.transfer((address >> 16) & 0xff);
  SPI.transfer((address >> 8) & 0xff);
  SPI.transfer(address & 0xff);
  digitalWrite(f_cs, HIGH);
  
  // Indicate that next I/O must wait for this write to finish
  flash_wait_for_write = 1;
}

If anyone has any advice or assistance on how to resolve this issue, I would greatly appreciate it.
 
That code is from the code that I wrote for the W25Q128FV chip. It won't work correctly on the 1Gbit chip. The 1Gbit chip is actually two 512Mbit chips each with their own chip select. The flash_erase_pages_sector code that you posted, and the rest of the code in the library you linked to, only uses one chip select pin. At best, it can only access 512Mbits.
The code would have to be (heavily?) modified to handle the 1Gbit chip.

Pete
 
That code is from the code that I wrote for the W25Q128FV chip. It won't work correctly on the 1Gbit chip. The 1Gbit chip is actually two 512Mbit chips each with their own chip select. The flash_erase_pages_sector code that you posted, and the rest of the code in the library you linked to, only uses one chip select pin. At best, it can only access 512Mbits.
The code would have to be (heavily?) modified to handle the 1Gbit chip.

Pete

Okay, thank you for your assistance, and of course the code I have been relying on so far. Your code seems to mostly work fine on the 1Gbit chip, so I hope the code modifications required are minimal. I will attempt to modify the code myself, but if you have any tips or advice, I would love to hear it.
 
Status
Not open for further replies.
Back
Top