diff options
Diffstat (limited to 'software_pwm.h')
-rw-r--r-- | software_pwm.h | 31 |
1 files changed, 31 insertions, 0 deletions
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 <stdint.h> + +#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 |