Test maximal GPIO output performance by toggling a GPIO output pin as fast as possible.
This mbed program creates a thread with Realtime Priority to do nothing but to toggle a GPIO output as fast as possible.
Measurements are performed on a NUCLEO-F767ZI board https://os.mbed.com/platforms/ST-Nucleo-F767ZI/.
- STM32F767ZIT6 @ 216 MHz
- Duration of high or low phases: 4 nsec - 10 nsec (resulting is something from 50 MHz to 125 MHz)
main.cpp@0:f122acadb07b, 2019-05-13 (annotated)
- Committer:
- stefanwaldschmidt
- Date:
- Mon May 13 12:28:40 2019 +0000
- Revision:
- 0:f122acadb07b
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
stefanwaldschmidt | 0:f122acadb07b | 1 | /* |
stefanwaldschmidt | 0:f122acadb07b | 2 | Test GPIO-output toggle time |
stefanwaldschmidt | 0:f122acadb07b | 3 | |
stefanwaldschmidt | 0:f122acadb07b | 4 | Hardware: NUCLEO-F767ZI |
stefanwaldschmidt | 0:f122acadb07b | 5 | STM32F767ZIT6 @ 216 MHz |
stefanwaldschmidt | 0:f122acadb07b | 6 | Libraries: |
stefanwaldschmidt | 0:f122acadb07b | 7 | mbed-os-5.12.3 |
stefanwaldschmidt | 0:f122acadb07b | 8 | Measured gpio_out frequency |
stefanwaldschmidt | 0:f122acadb07b | 9 | * total period: 8 nsec - 20 nsec (125 MHz - 50 MHz) |
stefanwaldschmidt | 0:f122acadb07b | 10 | */ |
stefanwaldschmidt | 0:f122acadb07b | 11 | |
stefanwaldschmidt | 0:f122acadb07b | 12 | #include "mbed.h" |
stefanwaldschmidt | 0:f122acadb07b | 13 | |
stefanwaldschmidt | 0:f122acadb07b | 14 | DigitalOut gpio_out(PC_8); |
stefanwaldschmidt | 0:f122acadb07b | 15 | |
stefanwaldschmidt | 0:f122acadb07b | 16 | void run() |
stefanwaldschmidt | 0:f122acadb07b | 17 | { |
stefanwaldschmidt | 0:f122acadb07b | 18 | while (true) { |
stefanwaldschmidt | 0:f122acadb07b | 19 | gpio_out = 1; |
stefanwaldschmidt | 0:f122acadb07b | 20 | gpio_out = 0; |
stefanwaldschmidt | 0:f122acadb07b | 21 | gpio_out = 1; |
stefanwaldschmidt | 0:f122acadb07b | 22 | gpio_out = 0; |
stefanwaldschmidt | 0:f122acadb07b | 23 | } |
stefanwaldschmidt | 0:f122acadb07b | 24 | } |
stefanwaldschmidt | 0:f122acadb07b | 25 | |
stefanwaldschmidt | 0:f122acadb07b | 26 | int main() |
stefanwaldschmidt | 0:f122acadb07b | 27 | { |
stefanwaldschmidt | 0:f122acadb07b | 28 | Thread *thread = new Thread(osPriorityRealtime); |
stefanwaldschmidt | 0:f122acadb07b | 29 | |
stefanwaldschmidt | 0:f122acadb07b | 30 | thread->start(run); |
stefanwaldschmidt | 0:f122acadb07b | 31 | |
stefanwaldschmidt | 0:f122acadb07b | 32 | while (true) { |
stefanwaldschmidt | 0:f122acadb07b | 33 | wait(0.1); // 100 ns |
stefanwaldschmidt | 0:f122acadb07b | 34 | } |
stefanwaldschmidt | 0:f122acadb07b | 35 | } |