Hi,
I wanted to count the incoming frequency on a GPIO pin (the input fre is around 50-150kHz)
I 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);
}
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
我得到错误的systick计时器的值input frequencies greater than 100kHz....Am I setting the GPIO interrupts correctly??
Hi mharthikote
It seems that the interrupts are correctly set.
I 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