I have been trying to deal with an issue regarding the SPI3 on the Nucleo-L432KC. The project uses both SPI ports (1 & 3), spi1 works nicely. Some code snipets show what I am up to below.
Code: Select all
#define THERM_CS_PORT GPIOA
#define THERM_CS_PAD 8
#define THERM_SPI_PORT GPIOB
#define THERM_SCK_PAD 3
#define THERM_MOSI_PAD 5
#define THERM_MISO_PAD 4
#define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008) // 21 MHz 10.5 MHz
////////////////////////
static SPIConfig spi_cfg_therm = {NULL,
THERM_CS_PORT,
THERM_CS_PAD, SPI_CR1_CPOL | SPI_CR1_CPHA |
SPI_BaudRatePrescaler_4,
0
};
/////////////////////////
palSetPadMode(THERM_SPI_PORT, THERM_SCK_PAD, PAL_MODE_ALTERNATE(6)|PIN_OSPEED_HIGH(THERM_SCK_PAD));
palSetPadMode(THERM_SPI_PORT, THERM_MOSI_PAD, PAL_MODE_ALTERNATE(6)|PIN_OSPEED_HIGH(THERM_MOSI_PAD));
palSetPadMode(THERM_SPI_PORT, THERM_MISO_PAD, PAL_MODE_ALTERNATE(6)|PIN_OSPEED_HIGH(THERM_MISO_PAD));
palSetPadMode(THERM_CS_PORT, THERM_CS_PAD, PAL_MODE_OUTPUT_PUSHPULL);
//////////////////////////
spiStart(&SPID3, &spi_cfg_therm);
//////////////////////////
spiStart(&SPID3, &spi_cfg_therm);
spiSelect(&SPID3);
spiExchange(&SPID3, VOSPI_FRAME_SIZE, tx, lepton_frame_packet);
spiUnselect(&SPID3);
spiStop(&SPID3);
The above code is only snipets, though the other parts of my code should not matter. I intend to read from a FLIR lepton module and my example is heavily based on this one https://github.com/groupgets/LeptonModule/tree/master/software/STM32F3Discovery_ChibiOS
I get only rubbish out, mostly 0s though there are the occasional lumps of data. The PB3 pin is SPI3_SCK though I know there can be issues with clash with JTDO/SWO, though I think the above code should deal with that with the setting alternative modes. I have also checked the DBGMCU_CR register and it seems that TRACE_IOEN is cleared (which should mean that SWO is not active).
Any other ideas for me to check?