куда копать уже не знаю.
mega64
avr studio 4
winavr
Код
#include <stdio.h>
#include <stdlib.h>
#include <avr/interrupt.h>
uint8_t sleep_value;
ISR(TIMER0_OVF_vect)
{
if (sleep_value>0) {sleep_value--;};
}
void timer_start()
{
// (CL_1)
TCCR0 = (1<<CS02)|(1<<CS00); // Timer Clock = system clock / 1024
// (CL_2.0)
TIFR = 1<<TOV0; // Clear TOV0 / Clear pending interrupts
// (CL_2.1)
TIMSK = 1<<TOIE0; // Enable Timer 0 Overflow Interrupt
}
void timer_sleep(uint8_t value)
{
sleep_value = value;
timer_start();
for(;;)
{
if (sleep_value == 0) break;
}
}
int main(void)
{
sei();
timer_sleep(2);
cli();
for(;;);
}
#include <stdlib.h>
#include <avr/interrupt.h>
uint8_t sleep_value;
ISR(TIMER0_OVF_vect)
{
if (sleep_value>0) {sleep_value--;};
}
void timer_start()
{
// (CL_1)
TCCR0 = (1<<CS02)|(1<<CS00); // Timer Clock = system clock / 1024
// (CL_2.0)
TIFR = 1<<TOV0; // Clear TOV0 / Clear pending interrupts
// (CL_2.1)
TIMSK = 1<<TOIE0; // Enable Timer 0 Overflow Interrupt
}
void timer_sleep(uint8_t value)
{
sleep_value = value;
timer_start();
for(;;)
{
if (sleep_value == 0) break;
}
}
int main(void)
{
sei();
timer_sleep(2);
cli();
for(;;);
}
