SB 0 .
15 (). , OCR 0 A. . . OCR 0 A, . , . 8 115, , , 0 x 73.
CodeVisionAVR, AVR Atmel.
, , 4.1.
4.1 ,
time | unsigned int | |
msec | unsigned int | |
sec | unsigned char | |
vivod | unsigned char | , |
count | unsigned char | |
cifri[] | unsigned char | |
temp | unsigned char | |
i | unsigned char |
- . 4.1...4.3.
. 4.1 -
. 4.2 - 15
. 4.2 -
, , .
/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.0 Professional
Automatic Program Generator
Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project:
Version:
Date: 16.05.2016
Author: NeVaDa
Company:
Comments:
Chip type: ATmega8
Program type: Application
AVR Core Clock frequency: 8,000000 MHz
Memory model: Small
External RAM size: 0
Data Stack size: 256
*****************************************************/
#include <mega8.h>
#include <delay.h>
|
|
flash unsigned char cifri[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F};
unsigned int msec = 0;
unsigned int time;
unsigned char sec;
unsigned char vivod;
unsigned char count;
void din_ind(int chislo)
{
unsigned char temp;
unsigned char i;
for(i = 2; i >= 1; i = i >> 1)
{
temp = chislo % 10;
chislo = chislo / 10;
PORTC = i;
PORTB = ~cifri[temp];
delay_ms(1);
}
}
// Timer1 output compare A interrupt service routine
interrupt [TIM1_COMPA] void timer1_compa_isr(void)
{
if(msec < 1000)
{
msec++;
}
else
{
msec = 0;
if(sec < 15)
{
sec++;
}
else
{
sec = 0;
vivod = count;
count = 0;
}
}
}
// Timer2 output compare interrupt service routine
interrupt [TIM2_COMP] void timer2_comp_isr(void)
{
if(time <= 700)
time++;
else
time = 0;
if(time >= 0 && time <= 40)
{
PORTD = 5*time;
}
else
if(time > 40 && time <= 200)
{
PORTD = 200;
}
else
if(time > 200 && time <= 300)
{
PORTD = -2*(time - 300);
}
else
{
PORTD = 0;
}
}
// Declare your global variables here
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0x80;
DDRB=0x7F;
// Port C initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=Out Func0=Out
// State6=T State5=T State4=T State3=T State2=P State1=0 State0=0
PORTC=0x04;
DDRC=0x03;
// Port D initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTD=0x00;
DDRD=0xFF;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x00;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 125,000 kHz
// Mode: CTC top=OCR1A
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: On
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x0B;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x73;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: 250,000 kHz
// Mode: CTC top=OCR2
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x0F;
TCNT2=0x00;
OCR2=18;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x90;
// USART initialization
// USART disabled
UCSRB=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
// ADC initialization
// ADC disabled
ADCSRA=0x00;
|
|
// SPI initialization
// SPI disabled
SPCR=0x00;
// TWI initialization
// TWI disabled
TWCR=0x00;
// Global enable interrupts
#asm("sei")
while (1)
{
if(PINC.2 == 0)
{
delay_us(200);
while(PINC.2 == 0)
{
}
delay_us(200);
count++;
}
din_ind(vivod);
}
}
5. ISIS proteus
. CSKEL Fuse. . Program file.
. 5.15.4.
. 5.1
. 5.2 SB 0 15
. 5.3 SB 0
15
. 5.4
, .
ARES PROTEUS. , , . , , , , Connectors, , (. 6.1).
. 6.1 ISIS ARES
. 6.26.4 . , .
. 6.2
. 6.3 p Cooper Silk
. 6.4 Bottom Cooper
3- D . 6.56.9.
. 6.5
. 6.6
. 6.7
. 6.8
. 6.9
ATmega 6450 , :
SB 0 15 . . 15 ( LCD -) 15 .
.
, , , , . .
1. .. AVR: / .. . .: , 2013 528 .
2. .. AVR Mega. / .. . .: -I, 2007 592 .
3. .. CodeVisionAVR: / .. .: -I, 2008 592 .
4. 6.050901 / ; .
.. . : - , 2010. 20 .