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

/media/uploads/stefanwaldschmidt/mbed-os-5.12.3.gif

OS 2

  • rising: 0.7 usec - 1.2 usec
  • falling: 0.8 usec - 1.3 usec

/media/uploads/stefanwaldschmidt/imag001.gif

Committer:
stefanwaldschmidt
Date:
Thu May 09 09:54:48 2019 +0000
Revision:
0:3c3c98b93d93
Child:
3:e4a312a8ad61
initial

Who changed what in which revision?

UserRevisionLine numberNew 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 0:3c3c98b93d93 5 Measured delay between gpio_in and gpio_out
stefanwaldschmidt 0:3c3c98b93d93 6 * rising: 0.7 usec - 1.2 usec
stefanwaldschmidt 0:3c3c98b93d93 7 * falling: 0.8 usec - 1.3 usec
stefanwaldschmidt 0:3c3c98b93d93 8 */
stefanwaldschmidt 0:3c3c98b93d93 9
stefanwaldschmidt 0:3c3c98b93d93 10 #include "mbed.h"
stefanwaldschmidt 0:3c3c98b93d93 11
stefanwaldschmidt 0:3c3c98b93d93 12 InterruptIn gpio_in(PC_8);
stefanwaldschmidt 0:3c3c98b93d93 13 DigitalOut gpio_out(PC_9);
stefanwaldschmidt 0:3c3c98b93d93 14
stefanwaldschmidt 0:3c3c98b93d93 15 void on_fall()
stefanwaldschmidt 0:3c3c98b93d93 16 {
stefanwaldschmidt 0:3c3c98b93d93 17 gpio_out = 0;
stefanwaldschmidt 0:3c3c98b93d93 18 }
stefanwaldschmidt 0:3c3c98b93d93 19
stefanwaldschmidt 0:3c3c98b93d93 20 void on_rise()
stefanwaldschmidt 0:3c3c98b93d93 21 {
stefanwaldschmidt 0:3c3c98b93d93 22 gpio_out = 1;
stefanwaldschmidt 0:3c3c98b93d93 23 }
stefanwaldschmidt 0:3c3c98b93d93 24
stefanwaldschmidt 0:3c3c98b93d93 25 int main()
stefanwaldschmidt 0:3c3c98b93d93 26 {
stefanwaldschmidt 0:3c3c98b93d93 27 gpio_in.fall(&on_fall);
stefanwaldschmidt 0:3c3c98b93d93 28 gpio_in.rise(&on_rise);
stefanwaldschmidt 0:3c3c98b93d93 29
stefanwaldschmidt 0:3c3c98b93d93 30 while (1) {
stefanwaldschmidt 0:3c3c98b93d93 31 wait(0.01); // 10 msec
stefanwaldschmidt 0:3c3c98b93d93 32 }
stefanwaldschmidt 0:3c3c98b93d93 33 }