From e811d778ea51ac1e25588a9cc957fca4f532ea5a Mon Sep 17 00:00:00 2001 From: Brett Weiland Date: Fri, 27 Oct 2023 07:10:26 -0500 Subject: init --- software_pwm.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 software_pwm.h (limited to 'software_pwm.h') diff --git a/software_pwm.h b/software_pwm.h new file mode 100644 index 0000000..1976c65 --- /dev/null +++ b/software_pwm.h @@ -0,0 +1,31 @@ +#ifndef SOFTWARE_PWM_H +#define SOFTWARE_PWM_H + +#include + +#define SOFTPWM_PIN_COUNT 8 +#define PWM_FREQ 300 //hz + +/** Our microcontroller we have laying around only has 4 hardware pwm channels. + * Because we want 8, we will create software PWM as an alternative. + * + * Notes to self to forcast nessessary optimizations (translates to color accuracy): + * Our error margin is 1/255th (13us at pwm freq 300hz) of a cycle. + * Cycles until next channel could be triggered: + * 209 at 16Mhz + * 130 at 10Mhz (have one available) + * 104 at 8Mhz + * 13 at 1Mhz (have one available) + * + * To decrease the amount of cycles every pwm timer interrupt, we'll generate the + * + * We might also want to make sure these values aren't updated every loop + * from random noise coming from the potentiometer. Test without, decide then. + */ + +void init_softpwm(); +void initilize_duty_cycle(uint8_t pin); +void softpwm_set(uint8_t pin, uint8_t duty); + + +#endif -- cgit v1.2.3