pokusim se na ATMELu tiny2313 rozchodit preruseni pri preteceni citace 0.
Kód: Vybrat vše
#include <avr/io.h>
#include <stdio.h>
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#define F_CPU 4000000UL // 4 MHz
int j,k;
ISR(TIM0_OVF_vect)
{
j++;
if(j >= 300){
if(PORTB == 0) PORTB = 0xFF;
else PORTB = 0x00;
j=0;
}
}
int main (void) {
// port B, ledka
PORTB = 0x00; //0x1C;
DDRB = 0xFF; //0x1C;
// port D
PORTD=0x00;
DDRD=0x00;
// time/counter 0
TCCR0A=0x00;
TCCR0B=0x05;
TCNT0=0x50;
OCR0A=0x00;
OCR0B=0x00;
// povoleni preruseni od citacu
TIMSK=0x02;
//globalni povoleni preruseni
sei();
j=0;
while(1) {
k=0;
}
return 0;
}
je to napsany ve WinAVR a vubec to nefunguje:( na vystupu tech pinu neni nic videt ani osciloskopem:(
kdyz dam do toho nekonecnyho cyklu
Kód: Vybrat vše
while(1){ if(PORTB == 0) PORTB = 0xFF;
else PORTB = 0x00;}
tak vystup normalne kmita. Nenapada Vas cim to muze byt?