Hi, as already said the demo SDK without any changes works. This days I have modified the demo, the chip select is handled as GPIO for both master and slave. The Master sends the data to the slave when I push the botton correctly , but if I start to menage the slave's chip select as GPIO the code doesn't work. I have configured the pin in the Slave side as a digital input, and I have initialized the GPIO port and pin.
gpio_pin_config_t led_config = {
kGPIO_DigitalInput,
};
GPIO_PortInit(GPIO, 0);
GPIO_PinInit(GPIO, 0, 23, &led_config);
BOARD_InitPins():
const uint32_t port0_pin23_config = (/* Pin is configured as GPIO */
IOCON_PIO_FUNC0 |
/* No addition pin function */
IOCON_PIO_MODE_INACT|
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT0 PIN28 (coords: 44) is configured as PIO0_28 */
IOCON_PinMuxSet(IOCON, 0U, 23U, port0_pin23_config);
I noticed that the state of the slave's chip select pin doesn't change and is always equals to 1, also when the master starts to send the data to the slave.
Why doesn't the code work, if I start to menage the slave's chip select as GPIO?
Below you can find the code about SPI master and slave.
MASTER:
for (i = 0; i < BUFFER_SIZE; i++)
{
srcBuff[i] = i;
}
while (1)
{
port_state = GPIO_PortRead(GPIO, APP_SW_PORT);
if ((!(port_state & (1 << APP_SW_PIN))))
{
/*Start Transfer*/
xfer.txData = srcBuff;
xfer.dataSize = 64;
xfer.configFlags = kSPI_FrameAssert;
GPIO_PinWrite(GPIO, 0, 4, 0);
SPI_MasterTransferBlocking(EXAMPLE_SPI_MASTER, &xfer);
GPIO_PinWrite(GPIO, 0, 4, 1);
for(i=0; i<10000000; i++) asm("NOP");
}
}
}
SLAVE:
for (i = 0; i < 64; i++)
{
sendBuff[i] = i;
}
while (1)
{
state= GPIO_PinRead(GPIO, 0, 23);
if (state==0){
flag=1;
}
/* receive data from master */
xfer.txData = sendBuff;
xfer.rxData = receiveBuff;
xfer.dataSize = sizeof(sendBuff);
SPI_SlaveTransferNonBlocking(EXAMPLE_SPI_SLAVE, &handle, &xfer);
while (slaveFinished != true)
{
}
}
}
in attach there is the screen shot of the logical analyzer.
BR