What is the fastest way to read a digital pin status in an Arduino Due? Is it possible to achieve speed in the Nanosecond area?
With which type of code I can achieve this?
Edit: This question is not a duplicate please see my comment.
What is the fastest way to read a digital pin status in an Arduino Due? Is it possible to achieve speed in the Nanosecond area?
With which type of code I can achieve this?
Edit: This question is not a duplicate please see my comment.
If the pin is declared as input, let's say pin 13:
uint32_t pin_status;
pin_status = PIOB->PIO_PDSR & PIO_PDSR_P27;
If the pin is declared as output, let's say pin 13:
uint32_t pin_status;
pin_status = PIOB->PIO_ODSR & PIO_ODSR_P27;
Also you will not find the appropiate answer to the question "the fastest" but only sadly an alternative to the digitalWrite.
You will not find any type of code example to set a pin as an input and to read from it, which actually for beginners like me would be very vital, if you would not forget that espiacially the "unnormal" register commands are very cryptic for a beginner.
– William Roy Mar 06 '17 at 19:50