Ronovar,
program ti ocigledno radi. Pogledaj program ispod i uporedi sa tvojim programom, cisto da vidis kako malo lepse da organizujes program.
program ti ocigledno radi. Pogledaj program ispod i uporedi sa tvojim programom, cisto da vidis kako malo lepse da organizujes program.
PHP Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#define LED_ON() PORTD |= 0b00000010
#define LED_OFF() PORTD &= 0b11111101
#define LED_TOGGLE() PORTD ^= 0b00000010
/* Initialize Timer1 */
void timer1_init(void){
/* Prescaler = 1024, CTC Mode */
TCCR1B |= (1<<WGM12)|(1<<CS12)|(1<<CS10);
/* Initialize Counter */
TCNT1 = 0;
/* Initialize Compare Value 1sec */
OCR1A = 18000;
/* Enable Compare Interrupt */
TIMSK1 |= (1<<OCIE1A);
}
/* LED Blink */
ISR (TIMER1_COMPA_vect){
/* Toggle LED */
LED_TOGGLE();
}
void Init_MCU(void)
{
DDRD |= (1<<1); // PORTD.1 is output
timer1_init(); // Initialization of the TMR1
sei(); // Enable Global Interrupts
}
int main(void)
{
Init_MCU(); // Initiazalition of the MCU
/* Replace With Your Application Code */
while (1)
{
}
}