Dynamically changing Interrupt GPIO edge source

Discussion around AT91RM9200 and SAM9 Series Products.

Moderator: nferre

jawad.sayed@e-blink.com
Posts: 2
Joined: Thu Jan 08, 2015 12:06 pm

Dynamically changing Interrupt GPIO edge source

Thu Jan 08, 2015 12:32 pm

On a SAM9x25 chip I want to calculate the time between pushing the bouton down to the time that user has released the button.

I have programmed an IO PIO_PA7 as an interrupt falling edge and when getting into the interrupt i am calling a sys_now function. Now inside that interrupt and before getting out from it i want to assign the same pin but with a rising edge condition and calling another function/handler when the rising edge occur to count the time that has passed between the two events.

I need to have interrupts because i am using this method when i have a problem into my main loop and thus i will only have interrupts to call functions. 

how can i do that in a baremetal system ? especially that i don't want to lose another GPIO interrupt that resides always on the rising edge of the PIO_PA26.
gerhardf
Posts: 554
Joined: Thu Dec 02, 2004 2:28 pm

Re: Dynamically changing Interrupt GPIO edge source

Thu Jan 08, 2015 2:28 pm

hello,
a pio generates an interrupt at the positive edge as well as at the negative edge.
the interrupt service routine has to read out the pio level.
resad carefully the chapter "Input Change Interrupt" at the datasheet.

regards
gerhard
jawad.sayed@e-blink.com
Posts: 2
Joined: Thu Jan 08, 2015 12:06 pm

Re: Dynamically changing Interrupt GPIO edge source

Thu Jan 08, 2015 5:40 pm

I am trying to know the following info :
- if a user presses the button for less than 1 second then : nothing to do
- if a user presses the button more than 1s and < 7s : do a normal reset
- if a user presses the button more than 7s : reboot with a factory version located at a specific position in the NandFlash 
jharley
Posts: 238
Joined: Thu Dec 06, 2012 6:40 am

Re: Dynamically changing Interrupt GPIO edge source

Thu Jan 08, 2015 6:50 pm

The approach that has worked for us:

Use the interrupt to determine something is happening on the key(button) input, then start your de-bounce algorithm (typically a polling method) to determine valid key(button) presses and how long they are pressed.

Return to “SAM9 ARM9 MPU”

Who is online

Users browsing this forum: No registered users and 3 guests