diff --git a/src/include/pwm.h b/src/include/pwm.h index 7e72af3..26430be 100644 --- a/src/include/pwm.h +++ b/src/include/pwm.h @@ -2,4 +2,4 @@ void pwm_init(void); void pwm_worker(void); -void test_pwm(void); \ No newline at end of file +void pwm_interrupt(void); \ No newline at end of file diff --git a/src/pwm.c b/src/pwm.c index 495105a..2f5ae85 100644 --- a/src/pwm.c +++ b/src/pwm.c @@ -10,7 +10,7 @@ uint32_t interrupt_counter = 0; void pwm_init(void) { - timer_subToT1Overflow(test_pwm); + tmr_subToT1Overflow(pwm_interrupt); } void pwm_worker() @@ -18,28 +18,9 @@ void pwm_worker() if (!interrupt_received) return; - double amp = 0.0; - - /* t_n is the time of nth pulse */ - /* factor 0.00005 because of 1/20 kHz */ - double t_n = interrupt_counter * 0.00005; - - amp = sin(2*M_PI*50*t_n); - - if (amp > 0.0) - timer_setT1CompareMatch((uint16_t)(amp * timer_getT1Top())); - else - timer_setT1CompareMatch(0); - - /* Let's wait for next interrupt */ - interrupt_received = 0; } -void test_pwm(void) +void pwm_interrupt(void) { - interrupt_received = 1; - interrupt_counter++; - if (interrupt_counter == 400) - interrupt_counter = 0; }