реклама на сайте
подробности

 
 
> Глюк с ATMEGA64 или где?, Таймер Т0 в асинхронном режиме.
DiaS
сообщение Aug 4 2005, 14:46
Сообщение #1





Группа: Новичок
Сообщений: 4
Регистрация: 1-08-05
Пользователь №: 7 263



Таймер Т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);
} blink.gif
Go to the top of the page
 
+Quote Post

Сообщений в этой теме


Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 20th July 2025 - 08:52
Рейтинг@Mail.ru


Страница сгенерированна за 0.01425 секунд с 7
ELECTRONIX ©2004-2016