added comment bout channel A
This commit is contained in:
@@ -71,7 +71,7 @@ int main() {
|
|||||||
|
|
||||||
TCCR1A |= (1 << COM1A0); // 14.3.1 : set Compare Output with COM1A0, it toggles OC1A on compare match (Table 16-1), OC1A is alternate function for PORTB1 (Table 14-3)
|
TCCR1A |= (1 << COM1A0); // 14.3.1 : set Compare Output with COM1A0, it toggles OC1A on compare match (Table 16-1), OC1A is alternate function for PORTB1 (Table 14-3)
|
||||||
|
|
||||||
OCR1A = TIME_MS(PERIOD); // Table 16-4 : set CTC compare value, the counter is cleared to zero when the counter value (TCNT1) matches the OCR1A register
|
OCR1A = TIME_MS(PERIOD); // Table 16-4 : set CTC compare value on channel A, the counter is cleared to zero when the counter value (TCNT1) matches the OCR1A register
|
||||||
|
|
||||||
TCCR1B |= (PRESCALE_SET(PRESCALE_VALUE));
|
TCCR1B |= (PRESCALE_SET(PRESCALE_VALUE));
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ int main() {
|
|||||||
|
|
||||||
ICR1 = TIME_MS(PERIOD); // Table 16-4 : set the period (compare TOP value)
|
ICR1 = TIME_MS(PERIOD); // Table 16-4 : set the period (compare TOP value)
|
||||||
|
|
||||||
OCR1A = TIME_MS(PERCENT(DUTY_CYCLE, PERIOD)); // 16.9.3 : set the duty cycle to DUTY_CYCLE% of the time -> OC1A (alternate function of PORTB1, aka LED2) is cleared when TCNT1 (the counter value) equals OCR1A
|
OCR1A = TIME_MS(PERCENT(DUTY_CYCLE, PERIOD)); // 16.9.3 : set the duty cycle to DUTY_CYCLE% of the time on channel A -> OC1A (alternate function of PORTB1, aka LED2) is cleared when TCNT1 (the counter value) equals OCR1A
|
||||||
|
|
||||||
TCCR1B |= (PRESCALE_SET(PRESCALE_VALUE)); // start the timer with the prescaler
|
TCCR1B |= (PRESCALE_SET(PRESCALE_VALUE)); // start the timer with the prescaler
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ int main() {
|
|||||||
|
|
||||||
ICR1 = TIME_MS(PERIOD); // Table 16-4 : set the period (compare TOP value)
|
ICR1 = TIME_MS(PERIOD); // Table 16-4 : set the period (compare TOP value)
|
||||||
|
|
||||||
OCR1A = TIME_MS(PERCENT(DUTY_CYCLE, PERIOD)); // 16.9.3 : set the duty cycle to DUTY_CYCLE% of the time -> OC1A (alternate function of PORTB1, aka LED2) is cleared when TCNT1 (the counter value) equals OCR1A
|
OCR1A = TIME_MS(PERCENT(DUTY_CYCLE, PERIOD)); // 16.9.3 : set the duty cycle to DUTY_CYCLE% of the time in channel A -> OC1A (alternate function of PORTB1, aka LED2) is cleared when TCNT1 (the counter value) equals OCR1A
|
||||||
|
|
||||||
TCCR1B |= (PRESCALE_SET(PRESCALE_VALUE)); // start the timer with the prescaler
|
TCCR1B |= (PRESCALE_SET(PRESCALE_VALUE)); // start the timer with the prescaler
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ void uart_printstr(const char* str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// print hello world, on serial port, every 2 seconds, with empty infinite loop
|
// print hello world, on serial port, every 2 seconds, with empty infinite loop
|
||||||
|
// `screen /dev/ttyUSB0 115200`
|
||||||
int main() {
|
int main() {
|
||||||
uart_init();
|
uart_init();
|
||||||
|
|
||||||
@@ -141,7 +142,7 @@ int main() {
|
|||||||
TIMSK1 |= (1 << OCIE1A); // Enable CTC interrupt
|
TIMSK1 |= (1 << OCIE1A); // Enable CTC interrupt
|
||||||
sei(); // Enable global interrupts
|
sei(); // Enable global interrupts
|
||||||
|
|
||||||
OCR1A = TIME_MS(PERIOD); // Table 16-4 : set CTC compare value, the counter is cleared to zero when the counter value (TCNT1) matches the OCR1A register
|
OCR1A = TIME_MS(PERIOD); // Table 16-4 : set CTC compare value on channel A, the counter is cleared to zero when the counter value (TCNT1) matches the OCR1A register
|
||||||
|
|
||||||
TCCR1B |= (PRESCALE_SET(PRESCALE_VALUE)); // 16.4 : set timer according to prescale value, in register TCCR1B, table 16-5 : prescale sets
|
TCCR1B |= (PRESCALE_SET(PRESCALE_VALUE)); // 16.4 : set timer according to prescale value, in register TCCR1B, table 16-5 : prescale sets
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user