SPI driver problem in LPC546xx

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

SPI driver problem in LPC546xx

14,918 Views
prasannanaik
Contributor III

Hi,

   I want to connect serial flash IC AT45DB641E to flexcomm interface 9 of LPC54608 development board OM13092. I am trying to read device ID of AT45DB641E which is 0x100281F but i am getting 0x281FFFFF. I think that only two bytes is getting received properly(0x281F). I have used pin 9 as sck, pin 11 as MISO, pin 13 as MOSI and pin 15 as ssel of J9 of development board. I have attached the code and the screen shot of the connection with AT45DB641E.

Please help.

Thanks and best regards,

Prasanna

Labels (1)
0 Kudos
Reply
6 Replies

14,532 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Prasanna Naik ,

In the interrupt function of your project,  "SPI_ReadData()" only can read 16 bits(2 bytes),

so you only read 0x281F. I recommend you use the function of "SPI_MasterTransferNonBlocking()" to  read ID .

I haven't find the better demo under LPC54608 SDK package, while there is a one under LPC54114 SDK, you can

have a look:

pastedImage_1.png

"spi_interrupt_flash" is interrupt project, use "SPI_MasterTransferNonBlocking()", "spi_polling_flash" is polling read the external flash data, use "SPI_MasterTransferBlocking()" function. The same function can find in LPC54608.

 


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

14,532 Views
prasannanaik
Contributor III

Hi Alice_Yang‌,

   I have tried the Non blocking transfer method as suggested by you. Now i am able to read the flash ID(i.e 0x100281F) but i am unable to write the data in flash. I am trying to write some data into a page of the flash but while reading the data from that address i am getting 0xFF. What could be the problem. I am unable to attach my latest code.

Thanks and best regards,

Prasanna

0 Kudos
Reply

14,532 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Prasanna,

I'm not sure the reason.  Please check the sector size of your flash, whether the address you write is suitable.

And whether you erase the sector before write.  Please check your code with datasheet of your flash and the demo

I mentioned before.


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

14,532 Views
prasannanaik
Contributor III

Hi Alice_Yang‌,

   I found the root cause of the issue. The chip select(CS) line "P3_30-FC9_SSELn0" is not deasserted properly by the spi engine. The CS line gets asserted on first function call "SPI_MasterTransferNonBlocking()" but it remains asserted throughout and doesn't change state. When i explicitly configured CS pin as gpio and operated as per the requirement, the system worked.

Why is this deassertion of CS line not happening properly i dont know.

Do you have any idea?.

Also, is there any problem if i configured the SS line as gpio?

Thanks and best regards,

Prasanna

0 Kudos
Reply

14,532 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Prasanna,

There is no problem configure the SS line to gpio, and I think using gpio to control SPI slave is more flexible.


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

14,532 Views
prasannanaik
Contributor III

Hi Alice,

   Thanks for your input. I will try it and let you know. Meanwhile i had following observations while debugging my code:

1) I should get only 5 interrupt, 1 for "SPITransmit(1, (uint8_t*)&uc_ReadDeviceID_Opcode);" and 4 for "SPIReceive(4, (uint8_t*)&ulDeviceID);" but i am getting 7 interrupt. 

2) The 7 interrupt result data is as follows:

   pastedImage_1.png

So the bytes 1,0,28,1f are getting received but it is taking two more spi clock automatically even when i am not sending dummy bytes in those two bytes. Please help in understanding this.

Thanks and best regards,

Prasanna

0 Kudos
Reply