Code:
#include <stdlib.h>#include <stdio.h>#include <string.h>#include "pico/stdlib.h"#include "pico/time.h"#define GPIO2 2#define GPIO15 15int main() { unsigned long count = 0; int in, out = 0; stdio_init_all(); gpio_init(GPIO2); gpio_init(GPIO15); gpio_set_dir(GPIO2, GPIO_OUT); gpio_set_dir(GPIO15, GPIO_IN); while (1) { gpio_put(GPIO2, out); printf("[%016lu] set GPIO2 to %d\n", to_ms_since_boot(get_absolute_time()), out); count = 0; while ((in = gpio_get(GPIO15)) != out) count++; printf("[%016lu] got GPIO15 to %d, count = %lu\n", to_ms_since_boot(get_absolute_time()), out, count); out = !out; sleep_ms(1000); } return 0;}This is my first time. I did the program above to test how fast GPIO15 follows GPIO2.
Code:
[0000000000052377] set GPIO2 to 0[0000000000052380] got GPIO15 to 0, count = 0[0000000000053384] set GPIO2 to 1[0000000000053387] got GPIO15 to 1, count = 0it takes to calculate number of milliseconds since boot. Still not sure how usb
packet processing could delay this. I will try to dig deeper into it, but I am not
sure..
Statistics: Posted by khalfella — Sun Sep 07, 2025 12:01 am










