Hi Dialog,
I have a problem with the interrupts on the DA14580 using SDK 5.0.3 and the ble peripheral example as a base. I am trying to get the DA14580 to interrupt on the rising edge of a pin from an external device.
However, no matter what I have tried the interrupt only occurs on the falling edge once the device releases the pin. This is for a time critical application so I need the interrupt to fire as soon as possible.
Any advice you have would be greatly appreciated, code and logic analyzer image attached.
Best wishes,
Tom
SetWord16(P29_MODE_REG,0x20); // Set as pull down
SetWord16(GPIO_IRQ2_IN_SEL_REG, 24); // P2.9 is selected, 2nd argument is pin - check datasheet
SetWord16(GPIO_RESET_IRQ_REG, 4); // Reset IRQ_2reg
SetBits16(GPIO_INT_LEVEL_CTRL_REG, EDGE_LEVELn2, 0); // 0: do not wait for key release after interrupt was reset for GPIO IRQ2
SetBits16(GPIO_INT_LEVEL_CTRL_REG, INPUT_LEVEL2, 0); // select rising edge
SetBits16(GPIO_DEBOUNCE_REG, DEB_ENABLE2, 0); // debounce enable
SetBits16(GPIO_DEBOUNCE_REG, DEB_VALUE, 0); // debounce time n * 0.63 ms
NVIC_SetPriority(GPIO2_IRQn,0);
NVIC_EnableIRQ(GPIO2_IRQn);
SetWord16(GPIO_RESET_IRQ_REG, 4); // Reset IRQ_2reg
嗨,汤姆,
Is there a reason that you are not using the GPIO_EnableIRQ function in the SDK?
This code snippet below is working. The interrupt is configured in the app_on_set_dev_config_complete callback (user_cfg_complete) to trigger on high level GPIO. An LED is turned on and a 1 second timer is started when the IRQ triggers. The timeout function turns the LED off and enables the interrupt again.
Hi,
Thank you very much for your quick response. I had tried using GPIO_EnableIRQ(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, GPIO0_IRQn, false, false, 0); but this also had no effect - the trigger was still on the falling edge. However I wasn't calling it in user_cfg_complete(void) or using default_app_on_set_dev_config_complete(); but setting the interrupt in periph_init(void).
I have added in the code you suggested and set the app_on_set_dev_config_complete to user_cfg_complete but unless I also add it to periph_init(void) it doesn't trigger and even using it as you have written it still triggers on the falling edge. Is there anything else I could be missing here... pin assignment, waking from sleep etc?
Best wishes,
Tom
嗨,汤姆,
如果您使用的是睡眠模式,这种类型的中断不会唤醒DA14580。醒来需要使用唤醒定时器块。有关唤醒定时器的详细信息,请参阅UM-B-51。如果时间真的至关重要,我会提醒您唤醒定时器要求GPIO保持在触发水平,以便超过2个睡眠时钟周期,以便唤醒设备(带有高达约61us的外部水晶。从睡眠中唤醒也需要大约1毫秒的芯片侧 - 例如改变时钟源,加电RAM电源轨等)
I am running the above code on my PRO development kit and the interrupts indeed trigger on the logically high level. I am using P1_1 as my input with pullup, thus releasing SW3 on the PRO kit will trigger the interrupt.
/MHv
Hi Dialog,
Thank you very much for your help. I managed to use the wake-up timer instead and it is working as planned now.
Best wishes,
Tom
That is great news!
/MHv