Hi there,
This post came of as a sequel of this post: https://community.nxp.com/message/827234?commentID=827234&et=watches.email.thread#comment-827234
I ll try to explain what i am trying to do and i need the manual gpio configuration.
I am trying to connect through spi an lpcxpresso4367 dev board with an esp8266 dev board. The main goal is to make a pcb with these two chips on board.
I am using the SSP1 controller from the side of LPC. The side of esp waits a format of 8 bits command + 8 bits address + 256 bits data.
As i figured out the automatic SSEL mechanism of SSP in LPC toggles thes SSEL between high and low between each 8 bit data tha is sent through SSP which is not my case.
So i needed a manual manipulation of SSEL and thats why i wanted to handle it as gpio, so that i can set it high and low each time i want to.
I connected the LPC to an oscilloscope and found out that clock works nice (clock works each time i m tyring to send sth not permanently).
MOSI and SSEL line (configured as gpio) are not behaving correctly.
I see MOSI data when SSEL is high and other weird things.
I tried to "wrap" send frame commands inside an setlow and sethigh SSEL.
I found out that not any time i use sendframe function the frame is sent and now i am tyring to understand the fifo mechanism when it is ready to send a frame and so on.
Now that you know what the big picture of my problem is can y give me any suggestion or help??
Thanks a lot in advance!
Solved! Go to Solution.
I found a solution and now manual gpio manipulation of SSEL works fine.
I set up a gpio pin (it doesn't matter if it is the same pin used like SSEL function or any other gpio).
In my case (SSP1 interface) pin 1.5 function 5 is SSP1 SSEL. I changed it to function 0 which is gpio.
Chip_SCU_PinMuxSet(0x1, 5, (SCU_PINIO_FAST | SCU_MODE_FUNC0)); /* P1.5 => SSEL1 */
After that i set up direction of pin to be output pin and set it high as default.
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0x1, 8); (pin P1_5 refers to gpio 1[8] according to datasheet)
Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0x1, 8, true);
Now every time i want to toggle ssel so that i can set it low before i send spi frames and set it true after sending I
made pin state false, i sent frame and then waited until the spi bus is not busy (using the BSY bit from _SSP_STATUS enum struct found in ssp_18xx_43xx.h)
Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0x1, 8, false);
Chip_SSP_RWFrames_Blocking(LPC_SSP, &xf_setup); (as used in the peripheral_spi example of LPCOpen)
if (Chip_SSP_GetStatus(LPC_SSP, SSP_STAT_BSY)) {
while (Chip_SSP_GetStatus(LPC_SSP, SSP_STAT_BSY)) {}
}
Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0x1, 8, true);
So SSEL gets low before i send sth and high after i send it.
I found a solution and now manual gpio manipulation of SSEL works fine.
I set up a gpio pin (it doesn't matter if it is the same pin used like SSEL function or any other gpio).
In my case (SSP1 interface) pin 1.5 function 5 is SSP1 SSEL. I changed it to function 0 which is gpio.
Chip_SCU_PinMuxSet(0x1, 5, (SCU_PINIO_FAST | SCU_MODE_FUNC0)); /* P1.5 => SSEL1 */
After that i set up direction of pin to be output pin and set it high as default.
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0x1, 8); (pin P1_5 refers to gpio 1[8] according to datasheet)
Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0x1, 8, true);
Now every time i want to toggle ssel so that i can set it low before i send spi frames and set it true after sending I
made pin state false, i sent frame and then waited until the spi bus is not busy (using the BSY bit from _SSP_STATUS enum struct found in ssp_18xx_43xx.h)
Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0x1, 8, false);
Chip_SSP_RWFrames_Blocking(LPC_SSP, &xf_setup); (as used in the peripheral_spi example of LPCOpen)
if (Chip_SSP_GetStatus(LPC_SSP, SSP_STAT_BSY)) {
while (Chip_SSP_GetStatus(LPC_SSP, SSP_STAT_BSY)) {}
}
Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0x1, 8, true);
So SSEL gets low before i send sth and high after i send it.