From: Ivan Stefanov Date: Tue, 24 Nov 2020 14:17:33 +0000 (+0200) Subject: Added TinkerCAD schematics for 2 Timer projects X-Git-Url: https://kolegite.com/gitweb/?a=commitdiff_plain;h=a53a47064efeb3a4508885e5bc448d257e803d2f;p=vmks.git Added TinkerCAD schematics for 2 Timer projects --- diff --git a/7-Bit-ASCII-Table-Transparent_Background.png b/7-Bit-ASCII-Table-Transparent_Background.png new file mode 100644 index 0000000..2494892 Binary files /dev/null and b/7-Bit-ASCII-Table-Transparent_Background.png differ diff --git a/7-Bit-ASCII-Table-White_Background.png b/7-Bit-ASCII-Table-White_Background.png new file mode 100644 index 0000000..0a3f997 Binary files /dev/null and b/7-Bit-ASCII-Table-White_Background.png differ diff --git a/Examples/Timer_1_COMPA_Toggle_pin_13_at_1Hz/Timer_1_COMPA_Toggle_pin_13_at_1Hz.png b/Examples/Timer_1_COMPA_Toggle_pin_13_at_1Hz/Timer_1_COMPA_Toggle_pin_13_at_1Hz.png new file mode 100644 index 0000000..bebc3db Binary files /dev/null and b/Examples/Timer_1_COMPA_Toggle_pin_13_at_1Hz/Timer_1_COMPA_Toggle_pin_13_at_1Hz.png differ diff --git a/Examples/Timer_1_COMPA_and_OVF_10kHz_Hardware_pin-9_and_Software_pin-13_PWM/Timer_1_COMPA_and_OVF_10kHz_Hardware_pin-9_and_Software_pin-13_PWM.ino b/Examples/Timer_1_COMPA_and_OVF_10kHz_Hardware_pin-9_and_Software_pin-13_PWM/Timer_1_COMPA_and_OVF_10kHz_Hardware_pin-9_and_Software_pin-13_PWM.ino new file mode 100644 index 0000000..a592e20 --- /dev/null +++ b/Examples/Timer_1_COMPA_and_OVF_10kHz_Hardware_pin-9_and_Software_pin-13_PWM/Timer_1_COMPA_and_OVF_10kHz_Hardware_pin-9_and_Software_pin-13_PWM.ino @@ -0,0 +1,54 @@ +void setup() { + // Set pin 13 to output + pinMode(13, OUTPUT); + + // Stop reception of interrupts + noInterrupts(); //cli(); + + // Set PB1 to be an output (Pin9 Arduino UNO) + DDRB |= (1 << PB1); + + // Clear Timer/Counter Control Registers + TCCR1A = 0; + TCCR1B = 0; + TIMSK1 = 0; + + // Set non-inverting mode - Table 15-3 (page 108) + TCCR1A |= (1 << COM1A1); + + // Set Fast-PWM Mode (Mode 14) - Table 15-5 (page 109) + TCCR1A |= (1 << WGM11); + TCCR1B |= (1 << WGM12); + TCCR1B |= (1 << WGM13); + + // Clear Timer 1 Counter + TCNT1 = 0; + + // Set PWM frequency/top value - Output PWM 10kHz + ICR1 = 199; // Fclk_io / (Fout * Prescaler) - 1 + OCR1A = 100; // Output OC1A will be ON for [OCR1A/(ICR1+1)]% of the time -> 100/(199+1) = 50% + + // Enable compare match interrupt + TIMSK1 |= (1 << OCIE1A); + TIMSK1 |= (1 << TOIE1); + + // Set prescaler to 8 and starts PWM + TCCR1B |= (1 << CS11); + + // Enables interrupts + interrupts(); //sei(); +} + +void loop() { + // Empty +} + +//Timer1 Compare Match Interrupt turns OFF pin 13 (LED) +ISR(TIMER1_COMPA_vect) { + digitalWrite(13, LOW); +} + +//Timer1 Overflow Interrupt turns ON pin 13 (LED) +ISR(TIMER1_OVF_vect) { + digitalWrite(13, HIGH); +} diff --git a/Examples/Timer_1_COMPA_and_OVF_10kHz_Hardware_pin-9_and_Software_pin-13_PWM/Timer_1_COMPA_and_OVF_10kHz_Hardware_pin-9_and_Software_pin-13_PWM.png b/Examples/Timer_1_COMPA_and_OVF_10kHz_Hardware_pin-9_and_Software_pin-13_PWM/Timer_1_COMPA_and_OVF_10kHz_Hardware_pin-9_and_Software_pin-13_PWM.png new file mode 100644 index 0000000..c664e27 Binary files /dev/null and b/Examples/Timer_1_COMPA_and_OVF_10kHz_Hardware_pin-9_and_Software_pin-13_PWM/Timer_1_COMPA_and_OVF_10kHz_Hardware_pin-9_and_Software_pin-13_PWM.png differ diff --git a/Examples/Timer_1_COMPA_and_OVF_10kHz_Software-PWM/Timer_1_COMPA_and_OVF_10kHz_Software-PWM.ino b/Examples/Timer_1_COMPA_and_OVF_10kHz_Software-PWM/Timer_1_COMPA_and_OVF_10kHz_Software-PWM.ino deleted file mode 100644 index a592e20..0000000 --- a/Examples/Timer_1_COMPA_and_OVF_10kHz_Software-PWM/Timer_1_COMPA_and_OVF_10kHz_Software-PWM.ino +++ /dev/null @@ -1,54 +0,0 @@ -void setup() { - // Set pin 13 to output - pinMode(13, OUTPUT); - - // Stop reception of interrupts - noInterrupts(); //cli(); - - // Set PB1 to be an output (Pin9 Arduino UNO) - DDRB |= (1 << PB1); - - // Clear Timer/Counter Control Registers - TCCR1A = 0; - TCCR1B = 0; - TIMSK1 = 0; - - // Set non-inverting mode - Table 15-3 (page 108) - TCCR1A |= (1 << COM1A1); - - // Set Fast-PWM Mode (Mode 14) - Table 15-5 (page 109) - TCCR1A |= (1 << WGM11); - TCCR1B |= (1 << WGM12); - TCCR1B |= (1 << WGM13); - - // Clear Timer 1 Counter - TCNT1 = 0; - - // Set PWM frequency/top value - Output PWM 10kHz - ICR1 = 199; // Fclk_io / (Fout * Prescaler) - 1 - OCR1A = 100; // Output OC1A will be ON for [OCR1A/(ICR1+1)]% of the time -> 100/(199+1) = 50% - - // Enable compare match interrupt - TIMSK1 |= (1 << OCIE1A); - TIMSK1 |= (1 << TOIE1); - - // Set prescaler to 8 and starts PWM - TCCR1B |= (1 << CS11); - - // Enables interrupts - interrupts(); //sei(); -} - -void loop() { - // Empty -} - -//Timer1 Compare Match Interrupt turns OFF pin 13 (LED) -ISR(TIMER1_COMPA_vect) { - digitalWrite(13, LOW); -} - -//Timer1 Overflow Interrupt turns ON pin 13 (LED) -ISR(TIMER1_OVF_vect) { - digitalWrite(13, HIGH); -}