File tree 3 files changed +60
-0
lines changed
examples/1.Basics/micros_430
hardware/msp430/cores/msp430 3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ //
2
+ // micros_430.ino
3
+ // Sketch
4
+ // ----------------------------------
5
+ // Developed with embedXcode
6
+ //
7
+ // Project micros
8
+ // Created by Rei VILO on 30/05/12
9
+ // Copyright © 2012 http://embeddedcomputing.weebly.com
10
+ // Licence CC = BY SA NC
11
+ //
12
+ //
13
+ // Based on Serial_430
14
+ // © Rei VILO 2012
15
+ // PUSH2 on pin 5
16
+ // Press push 2 to end and clear the serial port
17
+ //
18
+
19
+ // Core library
20
+ #if defined(__MSP430G2452__)
21
+ #include " Energia.h"
22
+ #else
23
+ #error MSP540G2452 required
24
+ #endif
25
+
26
+ #include " TimerSerial.h"
27
+ TimerSerial mySerial;
28
+
29
+ void setup () {
30
+ mySerial.begin ();
31
+ mySerial.print (" \n\n\n *** Serial test starts \n " );
32
+ mySerial.print (" PUSH2 to end\n " );
33
+ pinMode (PUSH2, INPUT_PULLUP);
34
+ }
35
+
36
+
37
+ void loop () {
38
+
39
+ mySerial.print (1.0 *millis (), 0 );
40
+ mySerial.print (" \t " );
41
+ mySerial.println (1.0 *micros (), 0 );
42
+ delay (500 );
43
+
44
+ if (digitalRead (PUSH2)==LOW) {
45
+ mySerial.print (" \n\n *** Serial test ends. \n " );
46
+ mySerial.end ();
47
+ while (true ); // endless loop
48
+ }
49
+ }
50
+
51
+
52
+
53
+
54
+
Original file line number Diff line number Diff line change @@ -141,6 +141,7 @@ extern const uint16_t port_to_input[];
141
141
142
142
// Implemented in wiring.c
143
143
void delayMicroseconds (unsigned int us );
144
+ unsigned long micros ();
144
145
unsigned long millis ();
145
146
146
147
#ifdef __cplusplus
Original file line number Diff line number Diff line change @@ -87,6 +87,11 @@ void initClocks(void)
87
87
const uint32_t WDT_FREQUENCY = SMCLK_FREQUENCY / WDT_DIVIDER ;
88
88
volatile uint32_t wdtCounter = 0 ;
89
89
90
+ unsigned long micros ()
91
+ {
92
+ return (1000 * wdtCounter ) / (WDT_FREQUENCY / 1000 );
93
+ }
94
+
90
95
unsigned long millis ()
91
96
{
92
97
return wdtCounter / (WDT_FREQUENCY / 1000 );
You can’t perform that action at this time.
0 commit comments