From d8e725275a51c7e8520e1dcbb0246461242ec357 Mon Sep 17 00:00:00 2001 From: flo66 Date: Wed, 11 Jan 2017 16:25:08 +0100 Subject: [PATCH] PWM --- src/Sound4Calc.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Sound4Calc.c b/src/Sound4Calc.c index d12d94e..8f9418c 100755 --- a/src/Sound4Calc.c +++ b/src/Sound4Calc.c @@ -9,7 +9,7 @@ //#define DEBUG //#define PI 3.141592653584 - +/* void switchStatePin() { if(isSH3()) @@ -20,8 +20,29 @@ void switchStatePin() { *(volatile unsigned char*)SH7305_PJDR ^= 0x04; } +}*/ + + +void lect440() +{ +unsigned char range = 1; + + if((0xEC88E >> range) & 1) + { + if(isSH3()) + { + *(volatile unsigned char*)SH7337_SCPDR ^= 0x01; + } + else + { + *(volatile unsigned char*)SH7305_PJDR ^= 0x04; + } + } + range = (range < 20 ? range + 1 : 1); } + + int main(void) { unsigned int key=0; @@ -40,6 +61,9 @@ int main(void) // PrintMini(1, 1, itoa(freq, str, 10), 0); dprint(1, 10, "%d", !isSH3()); + // dprint(1, 20, "%d", range); + + //PrintMini(1, 10, itoa(is_SH4, str, 10), 0); dupdate(); @@ -50,7 +74,8 @@ int main(void) case KEY_RIGHT : freq+=10; break; case KEY_LEFT : freq-=10; break; case KEY_EXE : - timer_start(TIMER_USER, 2*freq, Clock_Hz, switchStatePin, 4*freq); + timer_start(TIMER_USER, freq, Clock_Hz, lect440, 0); + break; case KEY_EXIT : timer_stop(TIMER_USER);