Jean-Paul PETILLON
/
test_usTimer
snippet to assess microsecond ticker reading function: uint32_t t = us_ticker_read();
main.cpp
- Committer:
- JPPetillon
- Date:
- 2020-01-24
- Revision:
- 0:677f08c93544
File content as of revision 0:677f08c93544:
//** * test_usTimer: test of us_ticker_read() function */ #include "mbed.h" int main() { // ensure that data is sent to serial on a char-per-char basis, otherwise .. setbuf(stdout, NULL); // .. it is sent on CR/LF or on buffer full printf("\033[2J"); // clear screen printf("*** Test of microsecond ticker reading [ us_ticker_read() ] ***\r\n"); printf(" Displays delta between 2 readings seperated by 'wait(1);'\r\n\r\n"); while(1) { uint32_t t0 = us_ticker_read(); wait(1); uint32_t t1 = us_ticker_read(); printf("\r"); wait(0.2); printf("%d", t1 - t0); } }