void init_pwm()
{
/* Async clock */
- PLLCSR = _BV(LSM) | _BV(PLLE);
+ PLLCSR = _BV(PLLE);
/* Synchronize to the phase lock */
_delay_ms(1);
TCCR1B = _BV(7) // PWM1X: PWM inversion mode
| _BV(CS10) // no clock prescaling
;
+ TC1H = 0x01;
OCR1C = 0xFF; // TOP value
+ TC1H = 0x00;
OCR1D = OCR1B = OCR1A = 0; // initial stride is 0
DDRB &= ~(_BV( PB1 ) | _BV( PB3 ) | _BV( PB5 )); // tristate it
void pwm_set(unsigned char n, unsigned char stride)
{
+ TC1H = 0x00;
switch (n) {
case 0: OCR1A = stride; break;
case 1: OCR1B = stride; break;
unsigned char pwm = pwm_probes[n];
#if 0
- log_byte(n);
log_byte(0xF4);
+ log_byte(n);
log_word(adcval);
#endif
pwm_off(n);
// pwm_set(n, 0);
pwmled_state[n] = ST_OFF;
- log_byte(n);
log_byte(0xF1);
+ log_byte(n);
return;
}
- if (pwm >= 0x60) { // over the maximum!
+ if (pwm >= 0x70) { // over the maximum!
+ pwm_off(n);
pwmled_state[n] = ST_DISABLED;
- log_byte(n);
log_byte(0xF2);
- pwm_off(n);
+ log_byte(n);
// pwm_set(n, 0);
return;
}