/*
* Filename: Normal_Mode_0
* Author: George Howard
* Date: 1/05/2024
* Description: PURPOSE – Get PORTA pin 7 to toggle every 0.5s.
* Mode of operation used: Mode 2 (CTC Mode).
*
*/
// Workings:
#include <avr/io.h>
#include <HardwareSerial.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
int main(void)
{
Serial.begin(9600);
cli(); // Disable all interrupts
DDRA = 0x80; // Set PORTA pin 7 as output
PORTA = 0x00;
OCR0A = 7812;
TCCR0A = (1 << WGM01); // Enable CTC mode
TCCR0B = (1 << CS02) | (1 << CS00); // Set prescaler to 1024
TIMSK0 |= (1 << OCIE0A); // Enable overflow interrupt
sei(); // Enable all interrupts
while (1)
{
;
}
}
ISR(TIMER0_COMPA_vect)
{
PORTA ^= 0x80;
}