Testing timer issues

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 DigitalOut led(PTB19); //green
00003 Serial pc(USBTX, USBRX); // tx, rx
00004 
00005 Ticker period;
00006 
00007 uint16_t j=0;
00008 
00009 void tick()
00010 {
00011 
00012     if (j<2500) {
00013         led=0;
00014     } else {
00015         led=1;
00016     }
00017 
00018     j++;
00019     j%=10000;
00020 
00021 }
00022 
00023 int main()
00024 {
00025   //  period.attach_us(tick,100); // serial and blink work
00026    period.attach_us(tick,20); //nope
00027 
00028 
00029     while (1) {
00030         pc.printf("j: %d\n\r",j );
00031       
00032     }
00033 
00034 }