Question about LPC SPIFI library enable quad SPI mode

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

Question about LPC SPIFI library enable quad SPI mode

2,717 Views
rawsewage
Contributor III

I was previously using lpclibspifi version 1.03 and I found the more recent version 1.14 bundled with MCUXpresso.

I have been looking through the differences and had a question about the function spifiDeviceDataSetOptsQuadModeBit9 which enables quad SPI mode.

The previous version of the function simply set the "quad enable" bit in the status registers, very straightforward.  However the new version of the function performs additional operations and I'm not sure what it's trying to accomplish.  See lines 760-785 of this image for the code in question.  I also attached the code to this post if that's easier.

Capture.PNG

I'd like to understand the new behavior to see if it's something I should incorporate, or if I should avoid the changes in an effort to reduce risk.  Thanks for any insight.

Labels (2)
Tags (2)
7 Replies

1,909 Views
koenvanderaa
Contributor II

Hi rawsewage,

Thanks for your post on this topic. I also checked your post on the topic from __placeholder____placeholder__

It looks like you are also working on the S25FL064L driver. Did you manage to make it working? I think my board is not booting because of this driver.

 

Have a nice day!

Koen 

0 Kudos
Reply

1,909 Views
rawsewage
Contributor III

Hi Koen - I spent a couple hours previously and did not get it working.  I moved on to adding other flash parts (Winbond, ISSI, etc.) because the S25FL064L has such a long lead time.  Even if I got it working, it wouldn't do me much good at the moment anyways.

I'm planning on getting back to it in the next couple weeks.  Now that I've spent more time with the SPIFI library, I think I'll be able to get it working without too much trouble.  I'd be happy to share my modifications with you when it's working, I just have some higher priority items I need to complete first.

Let me know if there are any questions I can help you with.

0 Kudos
Reply

1,909 Views
koenvanderaa
Contributor II

Hi rawsewage,

Thank you for your response. 

As I use the LPC4330 (without internal flash) I think this is a issue with the supported flash chip in the boot ROM. In the datasheet the S25FL064L is not in the list of supported devices.  So I will go for a different flash chip which is supported and try again to be sure. 

Have a nice day,

Koen 

0 Kudos
Reply

1,909 Views
rawsewage
Contributor III

OK I was able to get the S25FL064L working with the LPC1850.  Here's what I had to update in the LPC SPIFI library:

  • Define the flash part (JEDEC ID, parameters, etc.)
  • Create new GetStatus and SetStatus functions specifically for the S25FL064L to read/write four status registers (instead of three like the S25FL164K)
  • Create a new ReadCommand function specifically for the S25FL064L to set the dummy cycles accordingly (I only tested this with single speed and quad speed, haven't tried dual yet, so that one may need to be updated)
  • Use the same InitDeinit function as the S25FL164K to reset the latency configuration
  • Use the same ClearStatus function as the S25FL032P

I'm attaching a zip file containing the updated files, along with diff reports so you can see what I changed.  Notice that my library is modified from the original LPC SPIFI library, so you'll probably need to implement the changes manually into your library.

1,909 Views
rawsewage
Contributor III

Hi Carlos_Mendoza,

Thank you for taking the time to respond.  You are correct, I am looking at the examples that come with MCUXpresso.

That's what I found as well, that the spifiDeviceDataSetOptsQuadModeBit9 function exists for Micron parts, and the spifiDeviceDataSetOptsQuadModeBit9Simple exists for other parts.

However, I still see issues with the library.

First, the conditional compilation flags that are used to include/exclude parts from the build process are incorrect.  As I've copied here, you can see that the wrong parts are included with the wrong flags.  This is very misleading and should be corrected.

#define NEED_spifiDeviceDataSetOptsQuadModeBit9 (SPIFI_DEVICE_ALL | \
   SPIFI_DEVICE_S25FL016K | \
   SPIFI_DEVICE_S25FL032P | \
   SPIFI_DEVICE_S25FL064P | \
   SPIFI_DEVICE_S25FL129P_64K | \
   SPIFI_DEVICE_S25FL129P_256K | \
   SPIFI_DEVICE_S25FL164K | \
   SPIFI_DEVICE_S25FL256S_64K | \
   SPIFI_DEVICE_S25FL256S_256K | \
   SPIFI_DEVICE_S25FL512S | \
   SPIFI_DEVICE_W25Q80BV | \
   SPIFI_DEVICE_W25Q32FV | \
   SPIFI_DEVICE_W25Q64FV)

#define NEED_spifiDeviceDataSetOptsQuadModeBit9Simple (SPIFI_DEVICE_ALL |    SPIFI_DEVICE_GD25Q32C)

Second, almost all of the flash parts are defined and configured to use the wrong spifiDeviceDataSetOptsQuadModeBit9.  They should be using the "simple" version, but they are using the Micron version.  This is a mistake that needs to be corrected.

Third, there are other conditional complication flags that are simply missing.  For example, SPIFI_DEVICE_GD25Q32C is not actually defined anywhere.

My suggestion is to completely remove all of these conditional compilation flags (SPIFI_DEVICE_*, NEED_*).  They make the code difficult to read, they are out of date, and they are a maintenance nightmare.  If someone then wants to remove support for unneeded parts, they can simply delete them and be done with it.

I've done exactly this within my own code base, and it's so much easier to read.  I've also formatted the code to get consistent formatting (no tabs, consistent indentation, etc) and it looks much more professional now.

Anyways, just my two cents.  I hope these issues get corrected in the SPIFI library.  And I hope this is helpful to anyone which might read it.

1,909 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Rawsewage,

Thanks for your response and for your feedback, I will send it to the SPIFI library developers.

Best Regards!
Carlos Mendoza
Technical Support Engineer

0 Kudos
Reply

1,909 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Rawsewage,

Are you using the LPCOpen examples that come with MCUXpresso?

The usage of the spifiDeviceDataSetOptsQuadModeBit9 function or the spifiDeviceDataSetOptsQuadModeBit9Simple will depend on the device that you are using, you have to make sure the Flash memory being used supports the option. For example, the spifiDeviceDataSetOptsQuadModeBit9 function can be used with the Micron Flash:

pastedImage_1.png

If you can't find references to these commands on the manual of the memory that you are using is better continue using the spifiDeviceDataSetOptsQuadModeBit9Simple function.


Hope it helps!

Best Regards,
Carlos Mendoza
Technical Support Engineer