Using STM32F103RBT6 chip (Specifcally Olimex STM32- H103 Board), Keil u5. Communicating with AS5311 magnetic sensor
SPI peripheral is setup in master mode uni-directional rx only. CPHA = 1 and CPOL = 1. The clock pin is set as alternate function push pull. initialisation of SPI is below:
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES_RXONLY;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
hspi1.Init.NSS = SPI_NSS_SOFT;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLED;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
hspi1.Init.CRCPolynomial = 10;
HAL_SPI_Init(&hspi1);
I then enter a loop with the following code simply on a constant receive mode
while (1)
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_RESET);
HAL_SPI_Receive(&hspi1, (uint8_t *)Rx_Buffer, 3, HAL_MAX_DELAY);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_SET);
HAL_Delay(1);
}
I've checked the polarity and phase in the perihperhal viewer and can see the registers are set as 1 for both CPOL and CPHA. However when using a saleae logic analyser i can see that after transfer of data the clock does not idle high.
In terms of hardware the clock is directly connected with no pull up/down resistors.
Any ideas why the clock wont idle high?