STM32F4 connected to AM312 through ISR issue
Hello,
I have connected a sensor to my nucleo board to send data when sensor detects movement.
I have introduced an ISR for that.
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_0)
{
pirDetected = true;
}
}
unfortunatelly with that approach everytime the sensor was triggered ( I was able to measure 3.3v on the OUT pin using voltmeter) my stm32 is kind a freezing.
I have introduced some testcode,
extern "C" int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
while (1)
{
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0))
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);
HAL_Delay(5000); // Keep LED on for 5 seconds
}
else
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
}
HAL_Delay(100);
} /*Configure GPIO pin : PA0 */
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
...
/* EXTI interrupt init*/
HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
...with that my LED is on for about 5-6seconds and after that goes off, even when I am triggering the sensor, no reaction on led.
I am not sure what could be the reason, voltage is present when waving in front of the sensor.
AM312_OUT → PA0
AM312_vcc → 5v (have treid 3.3 as well)
AM312_GND → GND



sensor involved:
https://de.aliexpress.com/w/wholesale-am312-pir-sensor.html
Cheers
