[an error occurred while processing this directive]
Ответ:
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

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

Отправлено Max_Fly 15 января 2005 г. 01:38
В ответ на: эмм. ну давайте, ежели не трудно. отправлено 507 15 января 2005 г. 01:16

/* Moving LED example

CodeVisionAVR C Compiler
(C) 2000-2002 HP InfoTech S.R.L.
www.hpinfotech.ro

Chip: AT90S8515
Memory Model: SMALL
Data Stack Size: 128 bytes

8 LEDs are connected between the PORTC
outputs and +5V using 1K current
limiting resistors
The LEDs anodes are connected to +5V

On the STK500 it's only necessary to
connect the PORTC and LEDS headers
together with a 10-wire cable
*/

// I/O register definitions for AT90S8515
#include <90s8515.h>

// quartz crystal frquency [Hz]
#define xtal 3686400
// moving LED frequency [Hz]
#define fmove 2

// the LED on PORTC output 0 will be on
unsigned char led_status=0xfe;

// TIMER1 overflow interrupt service routine
// occurs every 0.5 seconds

interrupt [TIM1_OVF] void timer1_overflow(void)
{
// preset again TIMER1
TCNT1=0x10000-(xtal/1024/fmove);
// move the LED
led_status<<=1;
led_status|=1;
if (led_status==0xff) led_status=0xfe;
// turn on the LED
PORTC=led_status;
}

void main(void)
{
// set the I/O ports
// all PORTC pins are outputs
DDRC=0xff;
// turn on the first LED
PORTC=led_status;

// init TIMER1
// TIMER1 is disconnected from pin OC1
// no PWM
TCCR1A=0;
// TIMER1 clock is xtal/1024
TCCR1B=5;
// preset TIMER1
TCNT1=0x10000-(xtal/1024/fmove);
// clear TIMER1 interrupts flags
TIFR=0;
// enable TIMER1 overflow interrupt
TIMSK=0x80;
// all other interrupt sources are disabled
GIMSK=0;

// global enable interrupts
#asm
sei
#endasm

// the rest is done by TIMER1 overflow interrupts
while (1);
}

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

Ответы


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

Имя (обязательно): 
Пароль: 
E-mail: 

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

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

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


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

E-mail: info@telesys.ru