2013-10-24 01:47 AM
I'm using STM32F4 Discovery which includes LIS302DL among other peripherals. LIS302DL is connected via SPI and Interrupt Pin 1 and 2 are respectively connected to PE0 and PE1 pin (internally hardwired, not manually connected).
GPIO Pin E0 and E1 are configured as Input NOPULLRCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);GPIO_InitTypeDef GPIO_InitStructure;GPIO_InitStructure.GPIO_Pin = LIS302DL_SPI_INT1_PIN;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;GPIO_Init(LIS302DL_SPI_INT1_GPIO_PORT, &GPIO_InitStructure);GPIO_InitStructure.GPIO_Pin = LIS302DL_SPI_INT2_PIN;GPIO_Init(LIS302DL_SPI_INT2_GPIO_PORT, &GPIO_InitStructure);Accelerometer is configured as Interrupt Active High, PushPull and Interrupt generation on Data Ready (0x04 in CTRL_REG1)While data reading in main program loop works correctly, i need to read accelerometer when data ready interrupt is triggered in order to achieve a regular sample rate (i've also tried using a timer and it works correctly but i prefer drdy interrupt).Interrupt is only triggered (not always) at program startup, code works because if i connect pin to vdd, interrupt is triggered. I've not forgotten the clear pending bit line in interrupt handler.EXTI_ClearITPendingBit(EXTI_Line0);in void EXTI0_IRQHandler(void)If i touch the pin with an hand or a metallic object the interrupt is triggered (once) so i suspect this two things:- Accelerometer is not generating interrupts on data ready- Pin out (accelerometer) and In (PE0) are not correctly configured (PULLUP / DOWN / Open Drain etc)Also another thing: LIS302DL needs interrupt clearing? Have I to rewrite CTRL_REG3 back to 0x04 to re-enable interrupts? Does interrupts remain enabled?Thanks in advance #lis302dl-stm32f4discovery-int2013-12-27 04:37 AM
I've had the same problem, but I found a cheating workaround in the configuration:
After setting the same config on the accelerometer (active high IT on data ready), I initialized the EXTI and NVIC, but configured the GPIO pin to output, and pulled it down first, then switched it to input. This did the trick, but after further investigation, I found out the real problem: After setting up the interrupt generation, you need to read the latest data, because the data ready interrupt is only generated when the new data bits in the STATUS register switch from 0 to 1. If the interrupt handler does the data reading, the easiest way to do it is to call an EXTI_GenerateSWInterrupt() on the selected line. The above mentioned tricks most likely solved this problem because they all triggered the data reading once, and from that point the accelerometer can generate the interrupts itself.