DA14580 Interrupt

6 posts / 0 new
Last post
thomasburton
Offline
Last seen: 6 days 19 hours ago
Joined: 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

Device: 
Attachment: 
MHv_Dialog
Offline
Last seen: 18 hours 6 min ago
Staff
Joined: 2013-12-06 15:10
Hi Tom,

Hi Tom,

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: 6 days 19 hours ago
Joined: 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: 18 hours 6 min ago
Staff
Joined: 2013-12-06 15:10
Hi Tom,

Hi Tom,

If you are using sleep mode, this type of interrupt will not wake up the DA14580. Waking up requires the use of the wake-up timer block. Please see UM-B-51 for details on the wake-up timer. If timing is really critical, I would remind you that the wake-up timer requires the GPIO to remain in the triggering level for more than 2 sleep clock cycles in order to wake up the device (with an external crystal that adds up to about 61us and waking up from sleep also requires about 1ms of housekeeping on the chip side - such as changing the clock source, powering up the RAM power rail etc.) 

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: 6 days 19 hours ago
Joined: 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: 18 hours 6 min ago
Staff
Joined: 2013-12-06 15:10
That is great news! /MHv

That is great news!

/MHv