Таймер Т0 в асинхронном режиме.Подключен часовой кварц.
Предделитель делит на 128.ОС0 - в режиме выхода меандра.
Получаю 128 гц/256 ?
должно быть 128.Где собака порылась?
//ICC-AVR application builder : 04.08.2005 17:58:59
// Target : M64
// Crystal: 16.000Mhz
#include <iom64v.h>
#include <macros.h>
void port_init(void)
{
PORTA = 0x00;
DDRA = 0x00;
PORTB = 0x00;
DDRB = 0x10;
PORTC = 0x00; //m103 output only
DDRC = 0x00;
PORTD = 0x00;
DDRD = 0x00;
PORTE = 0x00;
DDRE = 0x00;
PORTF = 0x00;
DDRF = 0x00;
PORTG = 0x00;
DDRG = 0x00;
}
//TIMER0 initialize - prescale:128
// WGM: Normal
// desired value: 128Hz
// actual value: 128,000Hz (0,0%)
void timer0_init(void)
{
TCCR0 = 0x00; //stop
ASSR = 0x08; //set async mode
TCNT0 = 0xFE; //set count
OCR0 = 0xF2;
TCCR0 = 0x15; //start timer
}
#pragma interrupt_handler timer0_comp_isr:16
void timer0_comp_isr(void)
{
//compare occured TCNT0=OCR0
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
XDIV = 0x00; //xtal divider
XMCRA = 0x00; //external memory
port_init();
timer0_init();
MCUCR = 0x00;
EICRA = 0x00; //extended ext ints
EICRB = 0x00; //extended ext ints
EIMSK = 0x00;
TIMSK = 0x02; //timer interrupt sources
ETIMSK = 0x00; //extended timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
//
void main(void)
{
init_devices();
while(1);
}