EMG control program for use with Olimex ECG/EMG boards. Interacts with my OlimexChart Matlab programs to produce ECG or EMG strip chart displays. Also controls a relay for my Human-Human interface activity.

Dependencies:   mbed

Fork of TimeTests by Charles Tritt

Committer:
CSTritt
Date:
Mon Oct 30 14:42:40 2017 +0000
Revision:
0:cbee9f6e3fe9
Child:
1:d835bb04d8f0
Initial version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
CSTritt 0:cbee9f6e3fe9 1 /*
CSTritt 0:cbee9f6e3fe9 2 Project: TimeTests
CSTritt 0:cbee9f6e3fe9 3 File: main.cpp
CSTritt 0:cbee9f6e3fe9 4 Modified by by: Dr. C. S. Tritt
CSTritt 0:cbee9f6e3fe9 5 Last revision on: 9/28/17 (v. 1.0)
CSTritt 0:cbee9f6e3fe9 6
CSTritt 0:cbee9f6e3fe9 7 Experiments with time features of Nucleo boards. This millis timer reproduces
CSTritt 0:cbee9f6e3fe9 8 the Ardunio millis() function. It rolls over after 49.7 days. Responds to
CSTritt 0:cbee9f6e3fe9 9 serial characters by displaying millis and delta millis.
CSTritt 0:cbee9f6e3fe9 10
CSTritt 0:cbee9f6e3fe9 11 Note: The C time.h functions compile, but do not appear to return anything.
CSTritt 0:cbee9f6e3fe9 12 */
CSTritt 0:cbee9f6e3fe9 13 #include "mbed.h"
CSTritt 0:cbee9f6e3fe9 14
CSTritt 0:cbee9f6e3fe9 15 volatile unsigned int millis = 0; // Global millisecond counter.
CSTritt 0:cbee9f6e3fe9 16
CSTritt 0:cbee9f6e3fe9 17 Ticker milliTick; // Ticker to add milliseconds to millis.
CSTritt 0:cbee9f6e3fe9 18 Serial pc(USBTX, USBRX); // Serial connection to PC.
CSTritt 0:cbee9f6e3fe9 19
CSTritt 0:cbee9f6e3fe9 20 void milliIncr(void); // Callback that adds millisconds to millis.
CSTritt 0:cbee9f6e3fe9 21
CSTritt 0:cbee9f6e3fe9 22 int main()
CSTritt 0:cbee9f6e3fe9 23 {
CSTritt 0:cbee9f6e3fe9 24 unsigned int oldT; // Previous time value.
CSTritt 0:cbee9f6e3fe9 25 unsigned int newT; // Current time value.
CSTritt 0:cbee9f6e3fe9 26 milliTick.attach_us(milliIncr, 1000); // Adds milliseconds to millis.
CSTritt 0:cbee9f6e3fe9 27 while(true) {
CSTritt 0:cbee9f6e3fe9 28 if (pc.readable()) {
CSTritt 0:cbee9f6e3fe9 29 pc.putc(pc.getc()); // echo character(s).
CSTritt 0:cbee9f6e3fe9 30 oldT = newT;
CSTritt 0:cbee9f6e3fe9 31 newT = millis;
CSTritt 0:cbee9f6e3fe9 32 printf("\nt & Delta t: %u and %u.\n", newT, newT - oldT);
CSTritt 0:cbee9f6e3fe9 33 }
CSTritt 0:cbee9f6e3fe9 34 wait(0.2); // Poll port every 200 mS. About 28 mS loop time.
CSTritt 0:cbee9f6e3fe9 35 }
CSTritt 0:cbee9f6e3fe9 36 }
CSTritt 0:cbee9f6e3fe9 37
CSTritt 0:cbee9f6e3fe9 38 void milliIncr(void) // Call back that adds millisconds to millis.
CSTritt 0:cbee9f6e3fe9 39 {
CSTritt 0:cbee9f6e3fe9 40 millis++; // Increment by 10 milliseconds each time.
CSTritt 0:cbee9f6e3fe9 41 }