LPC1549 SPI how to use two CS lines?

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

LPC1549 SPI how to use two CS lines?

1,659 Views
Edrianocarlos
Contributor IV

Hello.

I am doing a lib to control ILI9341 Display and in order to send command or data i need to control two CS lines.

I am able to define and assert two CS with no problem, but i am not able to deassert only one. even when i write TXDAta plus CTRL the second CS would not go low.

the only way i am able to deassert is sending EOT + EOF but in this case both lines would go high again.

Does any one knows how to do that using this microcontroller?

thank you very much.

Labels (1)
Tags (2)
6 Replies

1,319 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Edriano Araujo,

    SPI read operation is the same as the write operation for the CS operation, before you read the data, pull the CS low, after you get all the data which you need, then pull CS high, here, you must make sure, the SPI bus wave meet your slave device read flow demand.

    Wish it helps you!

    If you still have question about it, please kindly let me know.


Have a great day,
Kerry

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

1,319 Views
chrispflieger
Contributor IV

Just read the bytes in and throw them away. That way you know exactly when the transfer is complete.

1,319 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Edriano,

    If you want to control the CS freely, I highly recommend you use the GPIO function to control your two CS lines, instead of use the SPI_CS hardware function.

    Please try to configure your two CS as GPIO, then use the GPIO to control the CS which meet your ILI9341 demand.

    Wish it helps you!


Have a great day,
Kerry

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

0 Kudos

1,319 Views
Edrianocarlos
Contributor IV

Hi Kerry,

I did this test using it as an GPIO, but as i am running the SPI at 12MHZ it is really hard to make it works as tx buffer is empty before the whole data outputs.

so i had to do a delay to make sure the data was sent and every time i change the spi frequency i had to change this delay manually.

So the way i am doing now is send a command finishing the frame then send the data. it is ok for writting onto display.

but is not ok to read from, as a read command demands CS low after command is high. 

0 Kudos

1,319 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Edriano,

  What's the SPI code you are using?

   Maybe you can use the SPI polling code, then to write and read, just check the according register, when the data is finished send and receive, then pull the CS manually.

If you still have problem about the read command, please give me your partial code, and the correct SPI wave which you want for your ILI9341 , actually, CS GPIO control is very freely, you can pull it in the SPI bus community anywhere. If after the read command, you need to pull high, then in your code, just in the command area, before you send the command, pull low CS, after you send the command, pull CS high.

  Any updated question, please kindly let me know.


Have a great day,
Kerry

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

0 Kudos

1,319 Views
Edrianocarlos
Contributor IV

Hi Kerry, thank you for the answer.

For now i have it working only for witting, there is not much need to read i will try nest time, now i am trying to read My sd card from the SPI.

0 Kudos