2019-11-04 12:15 AM
There is no peripheral clock available in specific for SPI in stm32l4xx_hal_rcc_ex.h, Could some one help which clock needs to be enabled for SPI1 communication
2019-11-04 12:56 AM
STM32Cube_FW_L4_V1.11.0\Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_rcc.h :
#define __HAL_RCC_SPI1_CLK_ENABLE() do { \
__IO uint32_t tmpreg; \
SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN); \
/* Delay after an RCC peripheral clock enabling */ \
tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN); \
UNUSED(tmpreg); \
} while(0)
JW
2019-11-04 03:26 AM
Hi @Community member ,
Thanks for the replay =)
I have enabled SPI1 clock as you have mentioned above.
I need to add it to PeriphClockSelection by picking from RCC_PeriphCLKInitTypeDef struct.
e.g.
RCC_PeriphCLKInitTypeDef PeriphClkInit = { 0 };
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2
| RCC_PERIPHCLK_USART3 | RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_I2C3 | RCC_PERIPHCLK_ADC
| RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_USB | RCC_PERIPHCLK_LPUART1;
Here with the struct RCC_PeriphCLKInitTypeDef I can see corresponding clocks for USART , I2C USB etc., are available, but SPI PERIPHCLK is not available.
Above the the code that I am using for PeriphClockSelection.
for example I have configured each clocksource as below:
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
PeriphClkInit.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1;
Similar way I am searching an clock source instance for SPI.
could you help/suggest what are the PeriphClockSelection I need to append here ?
Thanks
Dinesh
2019-11-04 03:47 AM
RCC_PERIPHCLK_*** are used only if the given peripheral has some dedicated setting in RCC.
SPI1 obviously has none such, it's simply directly clocked from its respective APB clock.
I don't use Cube.
JW
2019-11-04 04:11 AM
Thanks for the clue.
I would check for the respective APB clock configuration.
Will post a reply once arrived with a solution.
Thanks