Добавил:
Andrejjavd
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Примеры решения лабораторных работ / Лаб2
.txt//ICC-AVR application builder : 15.02.2021 11:15:10
// Target : M8535
// Crystal: 8.0000Mhz
#include <iom8535v.h>
#include <macros.h>
#include <io2313v.h>
#include <stdio.h>
void port_init(void)
{
PORTD = 0x00;
DDRD = 0xff;
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x00; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
void Delay(int i)
{
unsigned int p;
for (p=0;p<i;p++)
{
int tiks=1000000;
while (tiks>0)
tiks--;
}
}
//
void main(void)
{
int t[9]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x00};
int i=0;
init_devices();
while (1)
{
PORTD=t[i];
Delay(4);
i++;
if (i>=8)
i=0;
}
//insert your functional code here...
}