Callback take long time to trigger
MCU STM32L431, SYSCLK 80MHz
The callback takes 1.5us to fire from pin drop, and the callback functions take long time to execute as I show the image
the pin config function
/**
* @brief GPIO Initialization Function
* @param None
* @retval None
*/
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, Led1_Pin|Led2_Pin, GPIO_PIN_SET);
/*Configure GPIO pins : Led1_Pin Led2_Pin */
GPIO_InitStruct.Pin = Led1_Pin|Led2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pin : SPI1_NSS_Pin */
GPIO_InitStruct.Pin = SPI1_NSS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(SPI1_NSS_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : SPI1_SCK_ST_Pin */
GPIO_InitStruct.Pin = SPI1_SCK_ST_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(SPI1_SCK_ST_GPIO_Port, &GPIO_InitStruct);
/* EXTI interrupt init*/
HAL_NVIC_SetPriority(EXTI4_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI4_IRQn);
}
and callback function,
/* USER CODE BEGIN 4 */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
HAL_GPIO_WritePin(GPIOC, Led1_Pin, GPIO_PIN_SET);
// detect the SPI setting of the C2200, 1Mg bit or 200K bit
// SPI_PHASE_2EDGE, SPI_POLARITY_HIGH
if(HAL_GPIO_ReadPin(SPI1_SCK_ST_GPIO_Port, SPI1_SCK_ST_Pin))
{
const uint16_t CR1 = 0x0243;
WRITE_REG(hspi1.Instance->CR1, CR1);
}
// SPI_PHASE_1EDGE, SPI_POLARITY_LOW
else
{
const uint16_t CR1 = 0x0240;
WRITE_REG(hspi1.Instance->CR1, CR1);
}
HAL_GPIO_WritePin(GPIOC, Led1_Pin, GPIO_PIN_RESET);
}
/* USER CODE END 4 */
I suppose that at 80 MHz speed it should take a few nano seconds to trigger to callback function and execute the callback functions into a very short time
thanks in advance for your support