GPIO interrupt on rising edge

4 posts / 0 new
Last post
mharthikote
Offline
Last seen:5 years 6 months ago
Joined:2014-07-20 06:00
GPIO interrupt on rising edge

Hi,

我wanted to count the incoming frequency on a GPIO pin (the input fre is around 50-150kHz)
我plan to use GPIO interrupt on rising edge and count the systick timer to get the frequency value.
However I am not able to get correct value from systick timer, and I am not sure if I am setting up GPIO interrupts correctly

Can someone help me debug this issue

somefun()
{

//start systick timer
systick_usec_units(false);
systick_stop();
systick_start(90000, false);
//enable GPIO
GPIO_ResetIRQ(GPIO1_IRQn);
GPIO_EnableIRQ(GPIO_PORT_1,GPIO_PIN_1,GPIO1_IRQn,false,true,0); //want to trigger on rising edge signal
GPIO_RegisterCallback(GPIO1_IRQn,app_btn_callback();
...
}

void app_btn_callback(void)
{
if(firstEdge == 0)
{
firstEdge=1;
freqCount=SysTick->VAL;
}
else
{
freqCount=freqCount-SysTick->VAL;
systick_stop();
NVIC_DisableIRQ(GPIO1_IRQn);
}

NVIC_ClearPendingIRQ(GPIO1_IRQn);
}

Device:
MT_dialog
Offline
Last seen:2 weeks 1 hour ago
Staff
Joined:2015-06-08 11:34
Hi mharthikote,

Hi mharthikote,

What do you mean wrong values, what is the error from the values you are expecting?

Have you consider polling the GPIO and start the systick instead of waiting for an interrupt to occur and see what happens ?

Thanks MT_dialog

mharthikote
Offline
Last seen:5 years 6 months ago
Joined:2014-07-20 06:00
我get incorrect values from

我get incorrect values from the systick timer for input frequencies greater than 100kHz....Am I setting the GPIO interrupts correctly??

MT_dialog
Offline
Last seen:2 weeks 1 hour ago
Staff
Joined:2015-06-08 11:34
Hi mharthikote

Hi mharthikote

我t seems that the interrupts are correctly set.

我think though that the reason for not be able to work properly is the fact that you are using interrupts, trypolling the pin and see what happens.

Thanks MT_dialog