about the several GPIO interruptions in the same project

5 posts / 0 new
Last post
liuluan002
Offline
Last seen:5 months 4 weeks ago
加入:2015-11-27 14:24
about the several GPIO interruptions in the same project

Hi Dialog,

I am using the interruption from the pin P00 for the button press and relase. Also the pin P15 for the accelerator from the outside.

1. I also want to use the button press and button release to detect the button press time for the system.
2. I find my code is not stable, could you give me some suggestion for the solution, please?

void press_button(void)
{
if(GetBits16(SYS_STAT_REG, PER_IS_DOWN))
periph_init();

//P00 button press interruption
if(release_flag==0)
{
if((!(GetWord16(P0_DATA_REG) & (1 << 0 ))))
{
button_flag=3;
wkupct_register_callback(press_button);
wkupct_enable_irq(0x000001, 0x000000, 1, 0x14);
start_timer1(); // start to caculuate the press time
release_flag=1;
}

}

//P00 button release interruption
if(release_flag==1)
{
if(GetWord16(P0_DATA_REG) & (1 << 0 ))
{
wkupct_register_callback(press_button);
wkupct_enable_irq(0x000001, 0x000001, 1, 0x14);
stop_timer1();// stop to caculuate the press time, try to get how long button is pressed
release_flag==0;
}

}

//P15 accelerator interruption
if((GetWord16(P1_DATA_REG) & (1 << 5)))
{
wkupct_register_callback(press_button);
wkupct_enable_irq(0x002000, 0x000000, 1, 0x00); //P15
arch_ble_force_wakeup();
acc3(); //dealing with accelerator data
}

}

void user_app_init(void)
{
mnf_data_init();
default_app_on_init();
wkupct_register_callback(press_button);
wkupct_enable_irq(0x000001, 0x000001, 1, 0x14); //Button P00 waiting for the button press
wkupct_enable_irq(0x002000, 0x000000, 1, 0x00);//P15 INT1 watermark
}

Device:
liuluan002
Offline
Last seen:5 months 4 weeks ago
加入:2015-11-27 14:24
I have found the function

I have found the function "arch_ble_force_wakeup();" will destory the button release interruption and button press interruption. Is there any better method to solve the problem? since I need to call the "arch_ble_force_wakeup();" before the advertisement function also get the system time.

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi liuluan002,

Hi liuluan002,

What do you mean that the code is not stable, what happens ? Are you missing interrupts ? The wake up handler interrupt occurs but you dont see that the pin is set to '1' when you read the P1_DATA_REG (at the case of the interrupt from the sensor) ? Also in the user_app_init() you invoke two times the wkupct_enable_irq(), the second invocation will remove the settings of the first one, so from that point, i dont think that you will be able to wake up from a button, since only the P15 is set. I dont think that the arch_ble_force_wakeup() is going to affect the settings of the wakeup controller, when you leave the user_app_init() only the P15 is the available interrupt pin.

Thanks MT_dialog

liuluan002
Offline
Last seen:5 months 4 weeks ago
加入:2015-11-27 14:24
Hi DIalog,

Hi DIalog,

How to setup both the P15 with 1ms debouching time, also P00 with 20ms debouching time?

I have changes into the following code, seems both interruption works, but I want to make the P00 debouching time as 20ms, however the debouching time for P15 is 1ms. Do you know how to do it?

//niklas 20161207
void user_app_init(void)
{
mnf_data_init();
default_app_on_init();
wkupct_register_callback(press_button);

wkupct_enable_irq(0x002001, 0x000001, 1, 0x04);
}

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi liuluan002,

Hi liuluan002,

Only software debouncing, you cant set different debounce times for the wake up controller.

Thanks MT_dialog