[an error occurred while processing this directive]
|
//ICC-AVR application builder : 04.08.2005 17:58:59
// Target : M64
// Crystal: 16.000Mhz
#include void port_init(void) //TIMER0 initialize - prescale:128 #pragma interrupt_handler timer0_comp_isr:16 //call this routine to initialize all peripherals MCUCR = 0x00; //
E-mail:
info@telesys.ru
#include
{
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;
}
// 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
}
void timer0_comp_isr(void)
{
//compare occured TCNT0=OCR0
}
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();
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);
}
Ответы