test program to demonstrate the ticker problem in mbed lib v158, v159

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 Ticker *tokei ;
00003 uint32_t edge_time = 0 ;
00004 
00005 void inc_sec(void)
00006 {
00007     __disable_irq() ; // Disable Interrupts
00008     edge_time++ ;
00009     __enable_irq() ; // Enable Interrupts
00010 }
00011 
00012 void init_timer(void)
00013 {
00014     tokei = new Ticker() ;
00015     tokei->attach(inc_sec, 1.0) ;
00016 }
00017 
00018 int main() {
00019     uint32_t count = 0 ;
00020     init_timer() ;
00021     
00022     printf("Ticker test program\n") ;
00023     while(1) {
00024         printf("%d: %d\n", count++, edge_time) ;
00025         wait(1.0) ;
00026     }
00027 }