external GPIO interrupt on rising edge

Learn MoreFAQsTutorials

6 posts / 0 new
Last post
stanley_yeh
Offline
Last seen:1 year 6 months ago
加入:2016-12-23 06:52
external GPIO interrupt on rising edge

Hello,
I am using DA14585 with SDK 6.0.4, I also enabled ext-sleep mode.
A g-sensor is connected to a DA14585 through i2c. There is a interrupt pin.
The interruption of the sensor is designed as initially high, once the data ready, the interrupt pin will be low and then be high.
I would like to detect the rising edge for the interrupt pin, and I configure it as followings:

in void set_pad_functions(void):
GPIO_ConfigurePin(I2C_INT1_PORT, I2C_INT1_PIN, INPUT_PULLUP, PID_GPIO, true); //G Sensor INT1
GPIO_RegisterCallback( GPIO0_IRQn, LIS3DH_Interrupt1_Handler);
GPIO_EnableIRQ( I2C_INT1_PORT, I2C_INT1_PIN, GPIO0_IRQn, false, true, 3 );

in static inline void arch_goto_sleep (sleep_mode_t current_sleep_mode):
ext_wakeup_enable (I2C_INT1_PORT I2C_INT1_PIN 0);//0 => active high

However, I find that my callback function will be called every wake-up time.
The reason may be that the GPIO_EnableIRQ(in set_pad_functions) is set again and the interrupt pin is high at that time.
As I know, the GPIO interruption of DA14585 is level triggered, right?
Do you guys have any idea to solve this problem?
Thanks.

Device:
MT_dialog
Offline
Last seen:1 month 1 week ago
Staff
加入:2015-06-08 11:34
嗨stanley_yeh,

嗨stanley_yeh,

Well if the interrupt is high level triggered when the device wakes up, and sees that the GPIO is set to high the interrupt will be triggered.

Regarding the ext_wakeup_enable(), if your design is fully hosted (meaning the application runs on the 585 as well - which i suppose that it is) then its not needed. I assume that you would like to wake up the device if an interrupt is issued from the external sensor, that means that if the device is in sleep mode a normal GPIO IRQ will not wake up the device (unless if you are not using the sleep mode and you are always awake). So in order to wake up the device from sleep via interrupt you will have to use the wake up timer, you can have a look how to use this h/w in the ble_app_sleepmode project, also you will be able to find info regarding the wake up timer in the UM-B-079 DA14585/6 Software Platform Reference.pdf.

Regarding you issue with the GPIO IRQs, i assume that you are using sleep mode and you keep the interrupt line of the sensor high via the internal pullup of the 585, so in every wake up you essentially reset the interrupt to be triggered and since its allready triggered (since you have configured the pin as pull up) the ISR executes. Since you would like to detect a high pulse (i suppose that your sensor generates a high pulse in order to notify you for the data) you can configure your pin as INPUT_PULLDOWN, in order to detect a high pulse, if you are configuring the input as pull up then the interrupt will be generated always by the pullup of the pin.

Thanks MT_dialog

stanley_yeh
Offline
Last seen:1 year 6 months ago
加入:2016-12-23 06:52
Hi MT_dialog,

Hi MT_dialog,
Thank you for your prompt reply.
Sorry, I forget to mention that I have modified the ext_wakeup_enable() function and the external interrupt works well in sleep mode.

I'm a little confused, the interrupt line is set to high by the sensor, not DA14585.
The interrupt line is always high, once the data is ready, the interrupt line will be set to low and then be high.
What DA14584 can do is waiting for the rising edge then get the data.
I have tried. It doesn't seem to work if I modify the pin of DA14585 to INPUT_PULLDOWN and INPUT.
Could you please give me some suggestions?
Thanks a lot.

MT_dialog
Offline
Last seen:1 month 1 week ago
Staff
加入:2015-06-08 11:34
嗨stanley_yeh,

嗨stanley_yeh,

If the line is high by default and the interrupt GPIO_IRQn is configured to be triggered when the line is high as soon as the device will wake up and re-enable the interrupts the ISR will be executed if the line is high. If the sensor that you are using drops the line low as soon as it has data, then you should configure the interrupt to be triggered when the line is low not high thus GPIO_EnableIRQ(PORT_x,PIN_x,GPIO0_IRQn,true,true,3). If you dont want to start reading when the line is low but when the line is high again then you can try to set the interrupt to be triggered when the line is low and as soon as this interrupt hits, reset the interrupt and set it to trigger again when the line is high and as soon as the line gets high again the interrupt will be triggered again and then you can start reading data from the sensor, as soon as you 're done with the interaction you can set the IRQ trigger again back to low, in order not to hit on the next wake up.

Thanks MT_dialog

Kevleo94
Offline
Last seen:2 years 4 months ago
加入:2017-09-05 07:18
Hi Stanley. I want to ask you

Hi Stanley. I want to ask you, since I'm a little bit confused about interrupt. what pin did you use to communicate with i2c and why you choose GPIO0_IRQn?

stanley_yeh
Offline
Last seen:1 year 6 months ago
加入:2016-12-23 06:52
Following is my config:

Following is my config:
#define I2C_GPIO_SCL_PORT GPIO_PORT_0
#define I2C_SCL_PIN GPIO_PIN_7
#define I2C_GPIO_SDA_PORT GPIO_PORT_2
#define I2C_SDA_PIN GPIO_PIN_1
However, I think you can config any pin for i2c. It doesn't matter.
You can also use GPIO0_IRQn, GPIO1_IRQn, GPIO2_IRQn, GPIO3_IRQn or GPIO4_IRQn. Just chose one of them, that's no problem.
In this question, I just want to make sure the interrupt is level trigger.
Cheers :)