LPC55S06 SPI flash interface

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC55S06 SPI flash interface

881 Views
christianlees
Contributor III

Is there an SPI flash interface for the LPC55S06?  I want to use an SPI NOR flash chip to log data.  I won't need to boot from it as the internal flash will be large enough.

I can't seem to find any examples on interfacing to external flash parts.  Figured I'd see if there was one before I have to write one.

Labels (1)
0 Kudos
3 Replies

867 Views
christianlees
Contributor III

I figured as much when I couldn't find one.  For the benefit of others trying to do the same thing I found that this one works

https://github.com/pellepl/spiflash_driver

You'll need to control the CS pin as GPIO not through the SDK SPI code as it does not seem to toggle it so the flash chip doesn't behave.  My HAL code is as follows

int lpc_spiflash_spi_txrx(spiflash_t *spi, const uint8_t *tx_data,
	      uint32_t tx_len, uint8_t *rx_data, uint32_t rx_len)
{

	 spi_transfer_t xfer;
	 if(tx_len > 0)
	 {
		 xfer.txData = (uint8_t *)tx_data;
		 xfer.rxData = NULL;
		 xfer.dataSize = tx_len;
		 SPI_MasterTransferBlocking(SPI3, &xfer);
	 }

	 if(rx_len > 0)
	 {
		 xfer.txData = NULL;
		 xfer.rxData = rx_data;
		 xfer.dataSize = rx_len;
		 SPI_MasterTransferBlocking(SPI3, &xfer);
	 }

	 return SPIFLASH_OK;
}

void lpc_spiflash_spi_cs(spiflash_t *spi, uint8_t cs)
{
	GPIO_PinWrite(BOARD_INITPINS_FLASH_CS_GPIO, BOARD_INITPINS_FLASH_CS_PORT, BOARD_INITPINS_FLASH_CS_PIN, !cs);
}

void lpc_spiflash_wait(spiflash_t *spi, uint32_t ms)
{
	delay_ms(ms);
}

static const spiflash_hal_t my_spiflash_hal = {
  ._spiflash_spi_txrx = lpc_spiflash_spi_txrx,
  ._spiflash_spi_cs = lpc_spiflash_spi_cs,
  ._spiflash_wait = lpc_spiflash_wait
};

 

0 Kudos

861 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Yes,a spare IO is needed to enable SPI flash before using it.

0 Kudos

870 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi

I don't think we have SPI nor flash demo code.

I suggest you refer SPI demo code under LPC55S06 SDK folder to develop your SPI flash driver.

Have a nice day.

Jun Zhang

0 Kudos