From db74c734f32821fd84a8671e1b664f8120241361 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Fri, 14 Feb 2014 09:29:16 +0000 Subject: [PATCH] Add sine wave generator --- yue/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/yue/main.cpp b/yue/main.cpp index 150be36..3dfd736 100644 --- a/yue/main.cpp +++ b/yue/main.cpp @@ -224,9 +224,13 @@ void clock1_interrupt(void){ static int tchCnt; static int a2dCnt; static int ledCnt; + static int sinCnt; + + static float sinAmp = 0.5; // 0..1 + static float sinFreq = 0.25; // Hz // Write A2D output sine wave - //a2dOutput.write(sin(a2dCnt * TIME_ACCURACY * (2*PI) * 0.1)); + a2dOutput.write(sinAmp*sin(sinCnt * TIME_ACCURACY * (2*PI) * sinFreq)*0.5 + 0.5); // Send data through Serial if (accEnable && accCnt >= (int)(accTmr/TIME_ACCURACY+0.5)){ @@ -262,6 +266,7 @@ void clock1_interrupt(void){ tchCnt++; a2dCnt++; ledCnt++; + sinCnt++; sdma_flush(); } -- 2.43.2