Testing timer issues

Dependencies:   mbed

Committer:
vaxon
Date:
Tue Apr 09 01:20:54 2013 +0000
Revision:
3:8ca8be33da99
Parent:
2:2380496d04fd
Cleaner example. ; At 100ns, the green LED blinks on .25sec, off .75sec and serial prints "j"; At 20 it is locked up.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vaxon 0:f0632b06ba00 1 #include "mbed.h"
vaxon 3:8ca8be33da99 2 DigitalOut led(PTB19); //green
vaxon 0:f0632b06ba00 3 Serial pc(USBTX, USBRX); // tx, rx
vaxon 0:f0632b06ba00 4
vaxon 0:f0632b06ba00 5 Ticker period;
vaxon 0:f0632b06ba00 6
vaxon 0:f0632b06ba00 7 uint16_t j=0;
vaxon 0:f0632b06ba00 8
vaxon 0:f0632b06ba00 9 void tick()
vaxon 0:f0632b06ba00 10 {
vaxon 0:f0632b06ba00 11
vaxon 3:8ca8be33da99 12 if (j<2500) {
vaxon 0:f0632b06ba00 13 led=0;
vaxon 0:f0632b06ba00 14 } else {
vaxon 0:f0632b06ba00 15 led=1;
vaxon 0:f0632b06ba00 16 }
vaxon 0:f0632b06ba00 17
vaxon 3:8ca8be33da99 18 j++;
vaxon 0:f0632b06ba00 19 j%=10000;
vaxon 0:f0632b06ba00 20
vaxon 0:f0632b06ba00 21 }
vaxon 0:f0632b06ba00 22
vaxon 0:f0632b06ba00 23 int main()
vaxon 0:f0632b06ba00 24 {
vaxon 3:8ca8be33da99 25 // period.attach_us(tick,100); // serial and blink work
vaxon 3:8ca8be33da99 26 period.attach_us(tick,20); //nope
vaxon 0:f0632b06ba00 27
vaxon 0:f0632b06ba00 28
vaxon 3:8ca8be33da99 29 while (1) {
vaxon 3:8ca8be33da99 30 pc.printf("j: %d\n\r",j );
vaxon 3:8ca8be33da99 31
vaxon 3:8ca8be33da99 32 }
vaxon 0:f0632b06ba00 33
vaxon 0:f0632b06ba00 34 }