| uMIDI
    The swiss army knife for quick and easy developement of MIDI applications. | 
PWM configuration and service functions. More...


Go to the source code of this file.
| Macros | |
| #define | PWM_MAX_DUTY ((1L << lookup_table_resolution) - 1) | 
| Maximum duty cycle of the PWM.  More... | |
| Functions | |
| void | init_pwm_module (uint16_t(*conversion_function)(midi_value_t value)) | 
| Initializes the PWM.  More... | |
| void | set_pwm_duty_cycle (midi_value_t duty) | 
| Updates the PWM duty cycle.  More... | |
PWM configuration and service functions.
| #define PWM_MAX_DUTY ((1L << lookup_table_resolution) - 1) | 
Maximum duty cycle of the PWM.
| void init_pwm_module | ( | uint16_t(*)(midi_value_t value) | conversion_function | ) | 
Initializes the PWM.
CPU timer 1 is clocked with the system clock (32 MHz) and the compare output A is set up to output a dual slope PWM. Additionally, a conversion function which is used in set_pwm_duty_cycle() to compute the duty cycle compare values is registered.
| conversion_function | pointer to a function converting midi values to pwm compare register values | 
| void set_pwm_duty_cycle | ( | midi_value_t | duty | ) | 
Updates the PWM duty cycle.
Computes a suitable duty cycle compare value and writes the PWM counter compare register. This procedure can be used to manually control the modulation.
| duty | the desired duty cycle [0..MIDI_MAX_VALUE] | 
 1.8.13
 1.8.13