Test the response time from toggling a GPIO input to setting a GPIO output from the interrupt handler.
Measure the interrupt response time for a GPIO input
This mbed program registers "on rise" and "on fall" interrupt handlers for a GPIO input and drives a different GPIO output to follow the input.
Measurements are performed on a NUCLEO-F767ZI board https://os.mbed.com/platforms/ST-Nucleo-F767ZI/.
mbed-os-5.12.3
- rising: 1.1 usec - 1.3 usec
- falling: 1.1 usec - 1.3 usec
OS 2
- rising: 0.7 usec - 1.2 usec
- falling: 0.8 usec - 1.3 usec
main.cpp@3:e4a312a8ad61, 2019-05-10 (annotated)
- Committer:
- stefanwaldschmidt
- Date:
- Fri May 10 07:44:18 2019 +0000
- Revision:
- 3:e4a312a8ad61
- Parent:
- 0:3c3c98b93d93
upgrade form mbed 2 to mbed-os-5.12.3;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
stefanwaldschmidt | 0:3c3c98b93d93 | 1 | /* |
stefanwaldschmidt | 0:3c3c98b93d93 | 2 | Test interrupt response time |
stefanwaldschmidt | 0:3c3c98b93d93 | 3 | |
stefanwaldschmidt | 0:3c3c98b93d93 | 4 | Hardware: NUCLEO-F767ZI |
stefanwaldschmidt | 3:e4a312a8ad61 | 5 | Libraries: |
stefanwaldschmidt | 3:e4a312a8ad61 | 6 | mbed-os-5.12.3 |
stefanwaldschmidt | 0:3c3c98b93d93 | 7 | Measured delay between gpio_in and gpio_out |
stefanwaldschmidt | 3:e4a312a8ad61 | 8 | * rising: 1.1 usec - 1.3 usec |
stefanwaldschmidt | 3:e4a312a8ad61 | 9 | * falling: 1.1 usec - 1.3 usec |
stefanwaldschmidt | 0:3c3c98b93d93 | 10 | */ |
stefanwaldschmidt | 0:3c3c98b93d93 | 11 | |
stefanwaldschmidt | 0:3c3c98b93d93 | 12 | #include "mbed.h" |
stefanwaldschmidt | 0:3c3c98b93d93 | 13 | |
stefanwaldschmidt | 0:3c3c98b93d93 | 14 | InterruptIn gpio_in(PC_8); |
stefanwaldschmidt | 0:3c3c98b93d93 | 15 | DigitalOut gpio_out(PC_9); |
stefanwaldschmidt | 0:3c3c98b93d93 | 16 | |
stefanwaldschmidt | 0:3c3c98b93d93 | 17 | void on_fall() |
stefanwaldschmidt | 0:3c3c98b93d93 | 18 | { |
stefanwaldschmidt | 0:3c3c98b93d93 | 19 | gpio_out = 0; |
stefanwaldschmidt | 0:3c3c98b93d93 | 20 | } |
stefanwaldschmidt | 0:3c3c98b93d93 | 21 | |
stefanwaldschmidt | 0:3c3c98b93d93 | 22 | void on_rise() |
stefanwaldschmidt | 0:3c3c98b93d93 | 23 | { |
stefanwaldschmidt | 0:3c3c98b93d93 | 24 | gpio_out = 1; |
stefanwaldschmidt | 0:3c3c98b93d93 | 25 | } |
stefanwaldschmidt | 0:3c3c98b93d93 | 26 | |
stefanwaldschmidt | 0:3c3c98b93d93 | 27 | int main() |
stefanwaldschmidt | 0:3c3c98b93d93 | 28 | { |
stefanwaldschmidt | 0:3c3c98b93d93 | 29 | gpio_in.fall(&on_fall); |
stefanwaldschmidt | 0:3c3c98b93d93 | 30 | gpio_in.rise(&on_rise); |
stefanwaldschmidt | 0:3c3c98b93d93 | 31 | |
stefanwaldschmidt | 0:3c3c98b93d93 | 32 | while (1) { |
stefanwaldschmidt | 0:3c3c98b93d93 | 33 | wait(0.01); // 10 msec |
stefanwaldschmidt | 0:3c3c98b93d93 | 34 | } |
stefanwaldschmidt | 0:3c3c98b93d93 | 35 | } |