⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
6 posts / 0 new
Last post
thomasburton
Offline
Last seen:3 years 4 months ago
加入:2016-01-13 14:46
DA14580 Interrupt

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

Attachment:
Device:
MHv_Dialog
Offline
Last seen:1 month 2 weeks ago
工作人员
加入:2013-12-06 15:10
嗨,汤姆,

嗨,汤姆,

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.

void my_timer_timeout()
{
GPIO_ResetIRQ(GPIO0_IRQn);
NVIC_ClearPendingIRQ(GPIO0_IRQn);
GPIO_SetInactive(GPIO_ALERT_LED_PORT, GPIO_ALERT_LED_PIN);
NVIC_EnableIRQ(GPIO0_IRQn);
}
void my_btn_handler()
{
NVIC_DisableIRQ(GPIO0_IRQn);
arch_set_pxact_gpio();
GPIO_SetActive(GPIO_ALERT_LED_PORT, GPIO_ALERT_LED_PIN);
app_easy_timer(100,my_timer_timeout);
}
void user_cfg_complete(void)
{
default_app_on_set_dev_config_complete();
GPIO_RegisterCallback(GPIO0_IRQn, my_btn_handler);
GPIO_EnableIRQ(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, GPIO0_IRQn, false, false, 2);
GPIO_SetInactive(GPIO_ALERT_LED_PORT, GPIO_ALERT_LED_PIN);
}
/MHv
thomasburton
Offline
Last seen:3 years 4 months ago
加入:2016-01-13 14:46
Hi,

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

MHv_Dialog
Offline
Last seen:1 month 2 weeks ago
工作人员
加入:2013-12-06 15:10
嗨,汤姆,

嗨,汤姆,

如果您使用的是睡眠模式,这种类型的中断不会唤醒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

thomasburton
Offline
Last seen:3 years 4 months ago
加入:2016-01-13 14:46
Hi Dialog,

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

MHv_Dialog
Offline
Last seen:1 month 2 weeks ago
工作人员
加入:2013-12-06 15:10
That is great news! /MHv

That is great news!

/MHv