Hi there,
We are implementing a system in which we are detecting up to 1 MHz of PWM signal on the input GPIO pin.
Now the issue we are facing is high read latencies.
Here are test cases with the approaches I used:
First, we took a pair of input and output GPIOs.
Approach-1: Polling
Conclusion:
Approach-2: Using Interrupt
Conclusion:
So, my queries are as below:
Thanks and regards,
Pratham.
Hello @pratham_malaviya
I hope you are doing very well.
Theoretically, It should be possible, but accessing GPIOs through the general-purpose I/O registers (even when using bare metal) has inherent latencies due to memory access overhead.
You can try to use RTOS and use the taskENTER_CRITICAL() function and measure if there is an improvement.
I hope this can helps to you.
Best regards,
Salas.
Hi @Manuel_Salas ,
Thank you for your support!
As per your suggestion, I implemented it using RTOS, but some hard delays still remain.
I am attaching a code snippet and a logic analyzer capture for your reference.
Channel-1: Output GPIO
Channel-2: PWM signal fed to input GPIO.
I am still confused about these hard delays. The clock root for the GPIO is around 133 MHz, yet register access still takes a significant amount of time.
static void hello_task(void *pvParameters)
{
for (;;)
{
// PRINTF("Hello world.\r\n");
taskENTER_CRITICAL();
state = GPIO_PinRead(INPUT_GPIO,INPUT_GPIO_PIN);
GPIO_PinWrite(EXAMPLE_LED_GPIO,EXAMPLE_LED_GPIO_PIN,state);
taskEXIT_CRITICAL();
// vTaskSuspend(NULL);
}
}