forked from microbuilder/LPC810_CodeBase
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample53_sine_int16.c
More file actions
36 lines (32 loc) · 878 Bytes
/
example53_sine_int16.c
File metadata and controls
36 lines (32 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/********************************************************************************
*
* integer sin function speed test programm
*
********************************************************************************/
#include "arduino.h"
#include "sin_int16.h"
void setup() {
Serial_begin(9600);
}
#define CYCLES 65535
void loop() {
Serial_print("calculating ");
Serial_printnumber(CYCLES);
Serial_print(" sin values");
unsigned int n;
unsigned long start=millis();
for(n=0;n<CYCLES;n++)
{
volatile int x=sin_int16(n);
}
unsigned long stop=millis();
unsigned long duration=stop-start;
Serial_print(" time usage:");
Serial_printnumber(duration);
Serial_println("ms");
Serial_printnumber(duration*1000/CYCLES);
Serial_print(".");
Serial_printnumber((duration*10000/CYCLES)%10);
Serial_println("us per sine calculation");
delay(1000);
}