Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
2 years, 10 months ago.
SPI master and slave at the same time (NUCLEO-L432KC)
I'm testing my small project using SPI. In that project, the mbed board (Nucleo-L432KC) has to receive data from a SPI master, and send processed data to another device as a SPI master. Then, the board should 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?
- - - - - - - - - - - - - - --
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