[an error occurred while processing this directive]
В ATMEGE64 .Таймер 0 считает не так как надо? Должен выдать 128 гц.Получаю в 256 меньше.Изменение регистра OCR0 на вых. частоту не влияет.
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено DimaS 04 августа 2005 г. 18:28

//ICC-AVR application builder : 04.08.2005 17:58:59
// Target : M64
// Crystal: 16.000Mhz

#include
#include

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);
}


Составить ответ  |||  Конференция  |||  Архив

Ответы


Отправка ответа

Имя (обязательно): 
Пароль: 
E-mail: 
NoIX ключ Запомнить

Тема (обязательно):
Сообщение:

Ссылка на URL: 
Название ссылки: 

URL изображения: 


Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru