2022-01-07 05:10 AM
Hello,
i'm reading GPIO using internal instruction of GPIO_ReadPin function like "(GPIOC->IDR & GPIO_PIN_1)?1:0;" but i didn't get actual speed. So is there any alternative way to read GPIO fast ?
Regards,
Yash
2022-01-07 05:47 AM
What chip family? What speed do you reach and what CPU speed? What code? Code running in flash or ram?
2022-01-07 05:51 AM
GPIO access is usually much slower than MCU clock, even at register or assembler level access. Also depends on chip series.
2022-01-07 05:54 AM
In any case, there is no alternative to reading GPIO pin states other than reading IDR. You can use DMA, but it uses it the same access and will have the same drawbacks.
You could do something exotic like make it an SPI pin and read it indirectly that way, but not really recommended.
2022-01-07 11:09 PM
Checklist:
Do you need to read the pin fast for how long?
What is the maximum scan frequency?
Will the processor have enough time to keep up processing the data?
Is interrupt resilient?
Options with tradeoffs are
Dma read pin to memory ram
Timer capture to take a timestamp wheb signal toggles
Use exti to get notified or event trigger of dma on rise or fall edge....