Hi there,
I am trying to connect lpcxpresso 4367 with a wifi module (esp8266) through SPI (SSP1 in lpc). Lpc is spi master and wifi is spi slave.
I have some basic questions.
1. When i connect a device as spi slave in the clk, miso, mosi, ssel lines do i need an additional line for interrupts? Or by default the spi lines register an spi interrupt in the nvic interrupt handler by specific interrupts codes (like NVIC_EnableIRQ(SSP_IRQ))?
2. How do i set up ssel line to low so that data can be transmitted? Is ssel set to be low by default? In ssp.c example file of LPCOpen examples there is not any ssel initialization (or i can't find it).
3. Can nxp give a turorial or a rough roadmap how to connect spi slaves?
Please community and nxp help!
Hi Jingjing,
I have a doubt over your last comment.
As you said use GPIO as CS for control, Can the same SPI module's CS pin be configure as GPIO and use instead of using other pin for GPIO????
Hi Ahmed,
Yes, you can use the SPI module's CS pin, but just configure it as GPIO function, not the SPI_ssel function, then use GPIO control code instead of the SPI module automatically control.
Wish it helps you!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank you for your interest in NXP LPC product, I would like to provide service for you!
1. No, you don't need additional line for interrupts, just use the SPI interrupt is ok.
NVIC_EnableIRQ(SSP_IRQ);
And write the according interrupt service function.
2. You don't need to set up SSEL to low, because when you do the SPI data sending and receving, the SPI module will set it automatically.
The intialization for SSEL is in Board_SSP_Init, set the pin function as SPI SSEL function, take an example:
Chip_SCU_PinMuxSet(0x1, 5, (SCU_PINIO_FAST | SCU_MODE_FUNC5)); /* P1.5 => SSEL1 */
3. You can refer to the lpcopen code, you can download the code from this link:
After you download it, you can find the SSP code in folder:lpcopen_2_16_keil_iar_nxp_lpcxpresso_4337\applications\lpc18xx_43xx\iar\nxp_lpcxpresso_4337
About the tutor, just read the SSP sample code readme.
The connection between the master and slaver is:
master slave
MOSI MOSI
MISO MISO
SSEL SSEL
CLK CLK
Wish it helps you!
If you still have question, please let me know!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi there!
I had some problems and i want to set ssel manually.
How can i disable the automatic set to low of ssel and drive it manually?
Hi Dimitris,
When initialize the SSP module pin, don't initialize it as SSP function.
Please refer to lpcopen blinky code, just define it as the GPIO, and when you want to send data, set the gpio to low.
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanx for the reply,
So i initialize as gpio pin the same pin that is used for ssel just putting a different function?
Or i don't initialize ssel pin at all with any function and declare another pin with gpio funtion?
Thanx a lot in advance!
Hi Dimitris,
Both the same pin or another pin is ok.
But if you choose another pin, you should connect your ssel pin to the according GPIO in the hardware.
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi thanx for the the help.
If two slaves are connected to the same spi bus how ssel is changed to send data to one slave?
Hi Dimitris,
You can't connect two slaves in the same SPI bus directly, except that you use the different SSEL, you can choose another GPIO as the SSEL, but you need to use the code to control it.
Besides, you need to mask sure that if the slave is not selected, it's MOSI and MISO should be high, otherwise it will influence the other slave communication which already be select .
Wish it helps you!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
thanx again.
yes connect two spi slaves and control them with ssel. The ssel that is low will participate in data exchange. In order to do that i must set ssel1 low and ssel2 to high, right? how do i set value to ssel?
Hi Dimitris,
Because one SPI module just have one CS pin.
Now, if you want to use two CS pin, I suggest you don't use the SPI module's CS pin, just choose 2 GPIO as the CS pin.
Take an example, you have two SPI slave A and B.
Then you define two GPIO as CS1, CS2, CS1 for slave A, CS2 for slave B.
When you want to send data to slave A, just control CS1 pin, ouput the GPIO to low, control CS2's GPIO to high.
When you want to send data to slave B, it is the same, just CS1 to high, CS2 to low.
Wish it helps you!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------