Can I use two SPIs as a master and slave in one board? (Nucleo-L432KC)
I'm testing my small project using SPI.
In that project, the board, Nucleo-L432KC (used as a mbed board), has to receive data from a SPI master as a SPI slave, and send processed data to another device as a SPI master.
Then, the board has to work as a SPI slave and a SPI master at the same time.
Nucleo-L432KC has 2 SPI (SPI1 and SPI3) and so I tried to configure both of them, but SCLK output as a master didn't work.
Is it possible to use 2 SPI as a master and a slave?
Configuration
SPI1 as a slave
using MOSI = A6, MISO = A5, SCLK = A4, SSEL = D3
format:(8,3), frequency:6750000
SPI3 as a master
using MOSI = D11, MISO = D12, SCLK = D13, SSEL = D9
format:(8,3), frequency:6750000
If they are not configured at the same time, it seems to work well.
a part of my code:
SPI_3_SSEL = 1;
spi_3.format(SPI_3_BITS, SPI_3_MODE);
spi_3.frequency(SPI_3_FREQ);
SPI3->CR1 &= ~0x80; //MSBFirst
spi_1.format(SPI_1_BITS, SPI_1_MODE);
spi_1.frequency(SPI_1_FREQ);
SPI1->CR1 |= 0x80; //LSBFirst
SPI1->CR2 |= 0x40; //Interrupt
NVIC_SetVector(SPI1_IRQn, (uint32_t) &intrrptSPI1); //Callback function
NVIC_SetPriority(SPI1_IRQn, 1); //Priority
NVIC_EnableIRQ(SPI1_IRQn); //Enable interrupt