Understanding the setup

4 años 3 meses antes - 4 años 3 meses antes #2045 por Mireczko
Hello,
Is someone able to help me understand the ADC nad PWM setup? What are the values of chosen registers responsible for? Are there any possibilities to rewrite the code in more arduino-like way?

// setup ADC
ADMUX = 0x60; // left adjust, adc0, internal vcc
ADCSRA = 0xe5; // turn on adc, ck/32, auto trigger
ADCSRB = 0x07; // t1 capture for trigger
DIDR0 = 0x01; // turn off digital inputs for adc0

// setup PWM
TCCR1A = (((PWM_QTY - 1) << 5) | 0x80 | (PWM_MODE << 1)); //
TCCR1B = ((PWM_MODE << 3) | 0x11); // ck/1
TIMSK1 = 0x20; // interrupt on capture interrupt
ICR1H = (PWM_FREQ >> 8 );
ICR1L = (PWM_FREQ & 0xff);
DDRB |= ((PWM_QTY << 1) | 0x02); // turn on outputs
sei(); // turn on interrupts - not really necessary with arduino
}

Por favor, Identificarse para unirse a la conversación.

3 años 9 meses antes #2118 por Boris
Respuesta de Boris sobre el tema Understanding the setup
This is an elegant solution that reveals the full potential of the controller.
It’s better not to change these settings, because, in my opinion, they are very good.
Arduino functions are intended for widespread use in various tasks, they are also good, but they will be too slow for our task.

AnalogRead
Dual PWM Circuits
Timers on the ATmega168/328

Por favor, Identificarse para unirse a la conversación.

Tiempo de carga de la página: 0.053 segundos
Gracias a Foro Kunena
Joomla SEF URLs by Artio