#include <90s2313.h>
#include "HG.h"
// Timer 0 overflow interrupt service routine interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
// Reinitialize Timer's 0 value
TCNT0=0xFF;
// Place your code here
HG12();
}
// Timer 1 overflow interrupt service routine
interrupt [TIM1_0VF] void timer1_ovf_isr(void)
{
// Reinitialize Timer's 1 value
TCNT1H=0xf0;
TCNT1L=0xbe;
// Place your code here
N++;
if (N==20) N=0;
// Declare your global variables here
void main(void)
{
unsigned int temp,temp1,temp2;
// Input/Output Ports initialization
// Port В
P0RTB=0x00;
DDRB=0xFF;
// Port D
P0RTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 3906 kHz
// Mode: Output Compare
// OCD output: Disconnected
TCCR0=0x05;
TCNT0=0xFF;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 3,906 kHz
// Mode: Output Compare
// OC1 output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
TCCR1A=0x00;
TCCR1B=0x05:
TCNT1H=0xf0;
TCNT1L=0xbe;
0CR1H=0x00;
0CR1L=0x11;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
GIMSK=0x00;
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x82;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80:
// Global enable interrupts
#asm("sei")
init_HG();
while (1)
{
};
}
К нулевой линии порта В подсоединен транзисторный ключ, управляющий динамической головкой.
Микроконтроллер: AT90S2313.
Кварцевый резонатор: 4 МГц.
#include <90s2313.h>
// Процедура обработки прерывания Timer 1 по переполнению
interrupt [TIM1_0VF] void timer1_ovf_isr(void)
{
// Перезагрузить значение Timer 1
TCNT1H=0xff;
TCNT1L=0xfd;
if (PINB. 0–0) PORTB. 0=1; else P0RTB.0=0;
}
void main(void)
{
// Инициализация портов ввода/вывода
// Port В
DDRB=0xFF;
P0RTB=0x00;
// Port D
PORTD=0x00:
DDRD=0x00;
// Инициализация Timer 1
// Clock source: System Clock
// Clock value: 3906 kHz
// Mode: Output Compare
// OC1 output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
TCCR1A=0x00;
TCCR1B=0x05;
TCNT1H=0xff;
TCNT1L=0xfd;
0CR1H=0x00;
0CR1L=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x80;
P0RTB=0x00;
while (1);
}
К линиям 0, 1 и 2 порта В подсоединены соответственно красный, желтый и зеленый светодиоды.
Микроконтроллер: AT90S2313.
Кварцевый резонатор: 4 МГц.
Текст программы: