SPI debug for mode 1 on STM32G4 using HAL APIs
Hi Community, I recently worked on SPI in mode 1 and observed some miscellaneous behavior. Can anyone please confirm the configurations made to work with mode 1 are proper?
And when I use Hardware NSS Signal to Hardware NSS Output Signal there is no proper signaling (high at idle low when sending data) on SPI2_NSS even after setting pull-up in the GPIO Settings. So setting it up as GPIO_Output and controlling manually.
Please find the sample test code below
uint16_t tx_data = 0x25A5; // 0b 0010 0101 1010 0101
uint16_t rx_data = 0;
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET);
HAL_SPI_TransmitReceive(&hspi2, (uint8_t*) &tx_data, (uint8_t*) &rx_data, sizeof(tx_data), 10);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET);



Please find the captured signal

Signal definition:
| Signal | Purpose |
| Red | NSS (Controlled manually) |
| Green | SCK |
| Brown | MOSI |
The captured signal is wrong. The first data bit from the left should be 0 but is 1. In mode 1 raising edge of the SCK should alter the data bit and in falling edge should latch it.
The discussion points are:
- Why hardware NSS is not working? Is wrongly configured?
- Is SPI set to work in mode 1?
