Hello,
I'm trying to generate external interrupt for LIS2DE12 for motion detection but while OS_TASK_NOTIFY_WAIT() it's doing Starting CPU target... and i'm not able to get notified value for OS_TASK_NOTIFY_WAIT .Can you help me for it??
here is my configuration for interrupt generation..,
void wakeup_interrupt_cb(void)
{
hw_wkup_reset_interrupt();
OS_TASK_NOTIFY_FROM_ISR(acc_main_h, 0x1, OS_NOTIFY_SET_BITS);
}
static void LIS2_WakeupEventsTask( void *pvParameters )
{
int8_t wdog_id;
OS_BASE_TYPE ret;
uint32_t ulNotifiedValue;
lis2de12_int1_src_t src;
/* Accelerometer Interrupt Pins */
hw_gpio_configure_pin(HW_GPIO_PORT_0, HW_GPIO_PIN_12, HW_GPIO_MODE_INPUT_PULLUP, HW_GPIO_FUNC_GPIO, true); // ACCELEROMETER_INT1
hw_gpio_pad_latch_enable(HW_GPIO_PORT_0, HW_GPIO_PIN_12);
hw_gpio_pad_latch_disable(HW_GPIO_PORT_0,HW_GPIO_PIN_12);
hw_wkup_init(NULL);
hw_wkup_configure_pin(HW_GPIO_PORT_0,HW_GPIO_PIN_12, true, HW_WKUP_PIN_STATE_LOW);
hw_wkup_register_gpio_p0_interrupt (wakeup_interrupt_cb, 1);
/* Enable interrupts of WKUP controller */
hw_wkup_enable_irq();
/* Accelerometer-I2C Configuration */
li2de12_hdl = ad_i2c_open(LI2DE12);
sensor_init(li2de12_hdl);
enableWakeUpDetect(li2de12_hdl);
/* Register ble_multi_link task to be monitored by watchdog */
wdog_id = sys_watchdog_register(false);
for (;;) {
printf (" LIS2_WakeupEventsTask Task \r\n");
/* Notify watchdog on each loop */
sys_watchdog_notify(wdog_id);
/* Suspend watchdog while blocking on OS_TASK_NOTIFY_WAIT() */
sys_watchdog_suspend(wdog_id);
/* Wait on any of the notification bits, then clear them all */
ret = OS_TASK_NOTIFY_WAIT(0, OS_TASK_NOTIFY_ALL_BITS, &ulNotifiedValue, OS_TASK_NOTIFY_FOREVER);
/* This must block forever, until a task notification is received. So, the
return value must be OS_TASK_NOTIFY_SUCCESS */
OS_ASSERT(ret == OS_TASK_NOTIFY_SUCCESS);
/* Read INT pin 1 in polling mode
* or read src status register
*/
if(ulNotifiedValue & 0x1)
{
lis2de12_int1_gen_source_get(li2de12_hdl, &src);
if (src.xh || src.yh || src.zh)
{
hw_gpio_set_inactive(HW_GPIO_PORT_0, HW_GPIO_PIN_24);
hw_gpio_pad_latch_enable(HW_GPIO_PORT_0, HW_GPIO_PIN_24);
hw_gpio_pad_latch_disable(HW_GPIO_PORT_0,HW_GPIO_PIN_24);
enableWakeUpDetect(li2de12_hdl);
}
else
{
hw_gpio_set_active(HW_GPIO_PORT_0, HW_GPIO_PIN_24);
hw_gpio_pad_latch_enable(HW_GPIO_PORT_0, HW_GPIO_PIN_24);
hw_gpio_pad_latch_disable(HW_GPIO_PORT_0,HW_GPIO_PIN_24);
enableInactivityDetect(li2de12_hdl);
}
}
/* Main Application */
sys_watchdog_notify_and_resume(wdog_id);
}
}
Thanks & Regards,
Zinal.
Hi Zinal,
If I understood correctly, what you would like to accomplish is to wake-up the DA1469x via an external interrupt from the LIS2DE12. Is my assumption correct?
I would suggest first checking theDA1469x Tutorial External Interruption.
The key goals of this tutorial are to:
Thanks, PM_Dialog
Hello PM_Dialog,
Yes, You have understood correctly and also i followed up thisDA1469x Tutorial External Interruptionsame tutorial for this task .For my task it's starting the CPU...again while OS_TASK_NOTIFY_WAIT() that's my question why it's happening like this??? And also the way i have wrote that is correct or wrong?? Interrupt Handler not getting called for my case. what's the issue??
and here is my modified code for interrupt.. and with this also interrupt handler not getting called when motion is detect.
void wakeup_interrupt_cb(void)
{
hw_wkup_reset_interrupt();
uint32_t status;
/* Read the status of PORT0 */
status = hw_wkup_get_status(HW_GPIO_PORT_0);
/* Check the status of POTR0 */
if (status & (1 << HW_GPIO_PIN_12)) {
/* Notify the main task */
OS_TASK_NOTIFY_FROM_ISR(acc_main_h, 0x1, OS_NOTIFY_SET_BITS);
/* Clear the latch status */
hw_wkup_clear_status(KEY1_PORT, (1 << HW_GPIO_PIN_12));
/* Check the status of POTR0 */
}
}
static void LIS2_WakeupEventsTask( void *pvParameters )
{
int8_t wdog_id;
OS_BASE_TYPE ret;
uint32_t ulNotifiedValue;
lis2de12_int1_src_t src;
hw_wkup_init(NULL);
hw_wkup_register_gpio_p0_interrupt (wakeup_interrupt_cb, 1);
hw_wkup_gpio_configure_pin(HW_GPIO_PORT_0,HW_GPIO_PIN_12, true, HW_WKUP_PIN_STATE_LOW);
/* Enable interrupts of WKUP controller */
hw_wkup_enable_irq();
enableWakeUpDetect(li2de12_hdl);
/* Register ble_multi_link task to be monitored by watchdog */
// wdog_id = sys_watchdog_register(false);
for (;;) {
printf (" LIS2_WakeupEventsTask Task \r\n");
/* Notify watchdog on each loop */
sys_watchdog_notify(wdog_id);
/* Suspend watchdog while blocking on OS_TASK_NOTIFY_WAIT() */
sys_watchdog_suspend(wdog_id);
/* Wait on any of the notification bits, then clear them all */
ret = OS_TASK_NOTIFY_WAIT(0, OS_TASK_NOTIFY_ALL_BITS, &ulNotifiedValue, OS_TASK_NOTIFY_FOREVER);
/* This must block forever, until a task notification is received. So, the
return value must be OS_TASK_NOTIFY_SUCCESS */
OS_ASSERT(ret == OS_TASK_NOTIFY_SUCCESS);
/* Read INT pin 1 in polling mode
* or read src status register
*/
if(ulNotifiedValue & 0x1)
{
lis2de12_int1_gen_source_get(li2de12_hdl, &src);
if (src.xh || src.yh || src.zh)
{
hw_gpio_set_inactive(HW_GPIO_PORT_0, HW_GPIO_PIN_24);
hw_gpio_pad_latch_enable(HW_GPIO_PORT_0, HW_GPIO_PIN_24);
hw_gpio_pad_latch_disable(HW_GPIO_PORT_0,HW_GPIO_PIN_24);
enableWakeUpDetect(li2de12_hdl);
}
else
{
hw_gpio_set_active(HW_GPIO_PORT_0, HW_GPIO_PIN_24);
hw_gpio_pad_latch_enable(HW_GPIO_PORT_0, HW_GPIO_PIN_24);
hw_gpio_pad_latch_disable(HW_GPIO_PORT_0,HW_GPIO_PIN_24);
enableInactivityDetect(li2de12_hdl);
}
}
/* Main Application */
sys_watchdog_notify_and_resume(wdog_id);
}
}
static void prvSetupHardware( void )
{
hw_gpio_pad_latch_disable_all ();/ /……为了避免ny unused floating pins.
/*
* Add a PDC LUT entry so that to wake up the M33 core following an event on PORT0
* This is important since M33 is turned off when the device enters sleep.
*/
uint32_t pdc_wkup_gpio_id_1 = hw_pdc_add_entry(HW_PDC_LUT_ENTRY_VAL(HW_GPIO_PORT_0,
HW_GPIO_PIN_12, HW_PDC_MASTER_CM33, 0));
OS_ASSERT(pdc_wkup_gpio_id_1 != HW_PDC_INVALID_LUT_INDEX);
/* Do the trick! */
hw_pdc_set_pending(pdc_wkup_gpio_id_1);
hw_pdc_acknowledge(pdc_wkup_gpio_id_1);
/* Init hardware */
/* The 'periph_init()' will be called automatically
* now and on every wake-up of the device */
pm_system_init(periph_init);
/* Enable the COM power domain before handling any GPIO pin */
hw_sys_pd_com_enable();
/* Accelerometer Interrupt Pins */
hw_gpio_configure_pin(HW_GPIO_PORT_0, HW_GPIO_PIN_12, HW_GPIO_MODE_INPUT_PULLUP, HW_GPIO_FUNC_GPIO, true); // ACCELEROMETER_INT1
hw_gpio_pad_latch_enable(HW_GPIO_PORT_0, HW_GPIO_PIN_12);
hw_gpio_pad_latch_disable(HW_GPIO_PORT_0,HW_GPIO_PIN_12);
/* Disable the COM power domain after handling the GPIO pins */
hw_sys_pd_com_disable();
}
Hi Zinal,
Thanks for your comment here.
I’ve replied you in the following forum thread :
https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bluetooth-low-energy-%E2%80%93-software/da1469x-external-interrupt-not-invoking
Thanks, PM_Dialog